[cfe-commits] r116757 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-exprs.m

Douglas Gregor dgregor at apple.com
Mon Oct 18 15:01:46 PDT 2010


Author: dgregor
Date: Mon Oct 18 17:01:46 2010
New Revision: 116757

URL: http://llvm.org/viewvc/llvm-project?rev=116757&view=rev
Log:
Fix the translation of the PCC_ForInit code-completion context for
C++/C99/Objective-C, so that we properly include types. This fix
affects global caching of code-completion results; without caching,
the behavior was already correct.

Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/complete-exprs.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=116757&r1=116756&r2=116757&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Oct 18 17:01:46 2010
@@ -2589,9 +2589,15 @@
       
   case Sema::PCC_RecoveryInFunction:
     return CodeCompletionContext::CCC_Recovery;
-      
-  case Sema::PCC_Expression:
+
   case Sema::PCC_ForInit:
+    if (S.getLangOptions().CPlusPlus || S.getLangOptions().C99 ||
+        S.getLangOptions().ObjC1)
+      return CodeCompletionContext::CCC_ParenthesizedExpression;
+    else
+      return CodeCompletionContext::CCC_Expression;
+
+  case Sema::PCC_Expression:
   case Sema::PCC_Condition:
     return CodeCompletionContext::CCC_Expression;
       

Modified: cfe/trunk/test/Index/complete-exprs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-exprs.m?rev=116757&r1=116756&r2=116757&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-exprs.m (original)
+++ cfe/trunk/test/Index/complete-exprs.m Mon Oct 18 17:01:46 2010
@@ -11,6 +11,7 @@
 @implementation A
 - (int)method:(id)param1 {
   
+  for(BOOL B = YES; ; ) { }
 }
 @end
 
@@ -21,3 +22,8 @@
 // CHECK-CC1: macro definition:{TypedText NO} (65)
 // CHECK-CC1: NotImplemented:{ResultType A *}{TypedText self} (8)
 // CHECK-CC1: macro definition:{TypedText YES} (65)
+// RUN: c-index-test -code-completion-at=%s:14:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: TypedefDecl:{TypedText BOOL} (50)
+// CHECK-CC2: NotImplemented:{TypedText char} (50)
+// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30)





More information about the cfe-commits mailing list