[cfe-commits] r105152 - /cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Douglas Gregor
dgregor at apple.com
Sat May 29 23:10:08 PDT 2010
Author: dgregor
Date: Sun May 30 01:10:08 2010
New Revision: 105152
URL: http://llvm.org/viewvc/llvm-project?rev=105152&view=rev
Log:
Teach code-completion for calls to be more careful with a
potentially-NULL "function" argument.
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=105152&r1=105151&r2=105152&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Sun May 30 01:10:08 2010
@@ -2534,6 +2534,17 @@
};
}
+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 @@
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 @@
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?
More information about the cfe-commits
mailing list