[cfe-commits] r125715 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Index/complete-exprs.cpp

Douglas Gregor dgregor at apple.com
Wed Feb 16 19:09:23 PST 2011


Author: dgregor
Date: Wed Feb 16 21:09:23 2011
New Revision: 125715

URL: http://llvm.org/viewvc/llvm-project?rev=125715&view=rev
Log:
When Parser::ParseExpressionList isn't given a completer, fall back to
normal "expression" completion. Fixes the most annoying
code-completion bug I've found.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Index/complete-exprs.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=125715&r1=125714&r2=125715&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 16 21:09:23 2011
@@ -1801,6 +1801,8 @@
     if (Tok.is(tok::code_completion)) {
       if (Completer)
         (Actions.*Completer)(getCurScope(), Data, Exprs.data(), Exprs.size());
+      else
+        Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression);
       ConsumeCodeCompletionToken();
     }
     

Modified: cfe/trunk/test/Index/complete-exprs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-exprs.cpp?rev=125715&r1=125714&r2=125715&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-exprs.cpp (original)
+++ cfe/trunk/test/Index/complete-exprs.cpp Wed Feb 16 21:09:23 2011
@@ -20,6 +20,12 @@
   
 }
 
+int foo();
+
+void g() {
+  vector<int>(foo(), foo());
+}
+
 // RUN: c-index-test -code-completion-at=%s:20:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText operator} (40)
@@ -37,3 +43,11 @@
 // CHECK-CC2: ClassDecl:{TypedText string} (50)
 // CHECK-CC2-NOT: CXXConstructor
 // CHECK-CC2: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
+
+// RUN: c-index-test -code-completion-at=%s:26:15 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: NotImplemented:{TypedText float} (50)
+// CHECK-CC3: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{RightParen )} (50)
+// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{RightParen )} (50)
+// CHECK-CC3: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
+// CHECK-CC3: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder T const &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
+// CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)





More information about the cfe-commits mailing list