]> granicus.if.org Git - clang/commitdiff
Fix the translation of the PCC_ForInit code-completion context for
authorDouglas Gregor <dgregor@apple.com>
Mon, 18 Oct 2010 22:01:46 +0000 (22:01 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 18 Oct 2010 22:01:46 +0000 (22:01 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116757 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaCodeComplete.cpp
test/Index/complete-exprs.m

index 5b340d2e7b6336d566781e1f9d6033262c6d9c64..b07ae391f960cd339fb5ff7796d2732364546600 100644 (file)
@@ -2589,9 +2589,15 @@ static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S,
       
   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;
       
index a1933567f7e93eed83b7d67033c29034f064d2a3..9d11010ca4c6223c12ece53027a9efe89fac034f 100644 (file)
@@ -11,6 +11,7 @@ typedef signed char BOOL;
 @implementation A
 - (int)method:(id)param1 {
   
+  for(BOOL B = YES; ; ) { }
 }
 @end
 
@@ -21,3 +22,8 @@ typedef signed char BOOL;
 // 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)