diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-21 15:46:19 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-21 15:46:19 +0000 |
commit | ff59f676d04eeeabe29935d16d581ead23a21ef0 (patch) | |
tree | 088e00193a8f19163107573b00f6a54f82031c1f /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 232085d50a4f33b8590f32697ae32924c165fa61 (diff) | |
download | bcm5719-llvm-ff59f676d04eeeabe29935d16d581ead23a21ef0.tar.gz bcm5719-llvm-ff59f676d04eeeabe29935d16d581ead23a21ef0.zip |
Teach code-completion to deal with calls to functions without prototypes.
llvm-svn: 94076
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index a4cda014aae..fcd419bb10f 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -2234,30 +2234,36 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn, // FIXME: What if we're calling a pseudo-destructor? // FIXME: What if we're calling a member function? + typedef CodeCompleteConsumer::OverloadCandidate ResultCandidate; + llvm::SmallVector<ResultCandidate, 8> Results; + Expr *NakedFn = Fn->IgnoreParenCasts(); if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) AddOverloadedCallCandidates(ULE, Args, NumArgs, CandidateSet, /*PartialOverloading=*/ true); else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(NakedFn)) { FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl()); - if (FDecl) - AddOverloadCandidate(FDecl, Args, NumArgs, CandidateSet, - false, false, /*PartialOverloading*/ true); + if (FDecl) { + if (!FDecl->getType()->getAs<FunctionProtoType>()) + Results.push_back(ResultCandidate(FDecl)); + else + AddOverloadCandidate(FDecl, Args, NumArgs, CandidateSet, + false, false, /*PartialOverloading*/ true); + } } - // Sort the overload candidate set by placing the best overloads first. - std::stable_sort(CandidateSet.begin(), CandidateSet.end(), - IsBetterOverloadCandidate(*this)); + if (!CandidateSet.empty()) { + // Sort the overload candidate set by placing the best overloads first. + std::stable_sort(CandidateSet.begin(), CandidateSet.end(), + IsBetterOverloadCandidate(*this)); - // Add the remaining viable overload candidates as code-completion reslults. - typedef CodeCompleteConsumer::OverloadCandidate ResultCandidate; - llvm::SmallVector<ResultCandidate, 8> Results; - - for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(), - CandEnd = CandidateSet.end(); - Cand != CandEnd; ++Cand) { - if (Cand->Viable) - Results.push_back(ResultCandidate(Cand->Function)); + // Add the remaining viable overload candidates as code-completion reslults. + for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(), + CandEnd = CandidateSet.end(); + Cand != CandEnd; ++Cand) { + if (Cand->Viable) + Results.push_back(ResultCandidate(Cand->Function)); + } } if (Results.empty()) |