diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-05-30 06:10:08 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-05-30 06:10:08 +0000 | 
| commit | 6ed3eb8a48c35727ea1b1b526d6151cfd032bce5 (patch) | |
| tree | 40eb64caf66fdf9a4da2f38c5eb2793cdda7fe6e /clang/lib/Sema | |
| parent | c8731be34d18955bec1b71e172c978197c8f4ad7 (diff) | |
| download | bcm5719-llvm-6ed3eb8a48c35727ea1b1b526d6151cfd032bce5.tar.gz bcm5719-llvm-6ed3eb8a48c35727ea1b1b526d6151cfd032bce5.zip | |
Teach code-completion for calls to be more careful with a
potentially-NULL "function" argument.
llvm-svn: 105152
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 16 | 
1 files changed, 14 insertions, 2 deletions
| diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 339c46fde87..0b30da5d854 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -2534,6 +2534,17 @@ namespace {    };  } +static bool anyNullArguments(Expr **Args, unsigned NumArgs) { +  if (NumArgs && !Args) +    return true; +   +  for (unsigned I = 0; I != NumArgs; ++I) +    if (!Args[I]) +      return true; +   +  return false; +} +  void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn,                              ExprTy **ArgsIn, unsigned NumArgs) {    if (!CodeCompleter) @@ -2548,7 +2559,7 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn,    Expr **Args = (Expr **)ArgsIn;    // Ignore type-dependent call expressions entirely. -  if (Fn->isTypeDependent() ||  +  if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args, NumArgs) ||        Expr::hasAnyTypeDependentArguments(Args, NumArgs)) {      CodeCompleteOrdinaryName(S, CCC_Expression);      return; @@ -2572,7 +2583,8 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn,    else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(NakedFn)) {      FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl());      if (FDecl) { -      if (!FDecl->getType()->getAs<FunctionProtoType>()) +      if (!getLangOptions().CPlusPlus ||  +          !FDecl->getType()->getAs<FunctionProtoType>())          Results.push_back(ResultCandidate(FDecl));        else          // FIXME: access? | 

