[cfe-commits] r94076 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/call.c
Douglas Gregor
dgregor at apple.com
Thu Jan 21 07:46:19 PST 2010
Author: dgregor
Date: Thu Jan 21 09:46:19 2010
New Revision: 94076
URL: http://llvm.org/viewvc/llvm-project?rev=94076&view=rev
Log:
Teach code-completion to deal with calls to functions without prototypes.
Added:
cfe/trunk/test/CodeCompletion/call.c (with props)
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=94076&r1=94075&r2=94076&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Jan 21 09:46:19 2010
@@ -2234,30 +2234,36 @@
// 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));
-
- // 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));
+ 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.
+ for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
+ CandEnd = CandidateSet.end();
+ Cand != CandEnd; ++Cand) {
+ if (Cand->Viable)
+ Results.push_back(ResultCandidate(Cand->Function));
+ }
}
if (Results.empty())
Added: cfe/trunk/test/CodeCompletion/call.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/call.c?rev=94076&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/call.c (added)
+++ cfe/trunk/test/CodeCompletion/call.c Thu Jan 21 09:46:19 2010
@@ -0,0 +1,15 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+void f0(float x, float y);
+void f1();
+void test() {
+ f0(0, 0);
+ g0(0, 0);
+ f1(0, 0);
+ // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:6 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: f0(<#float x#>, float y)
+ // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CC2 %s
+ // CHECK-CC2: f0(float x, <#float y#>)
+ // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC3 %s
+ // CHECK-CC3: f1()
+}
Propchange: cfe/trunk/test/CodeCompletion/call.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CodeCompletion/call.c
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CodeCompletion/call.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list