]> granicus.if.org Git - clang/commitdiff
[libclang] Always report a CXCursor_MacroDefinition for code-completion
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 27 Sep 2012 00:24:09 +0000 (00:24 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 27 Sep 2012 00:24:09 +0000 (00:24 +0000)
results for a macro name, not CXCursor_NotImplemented.

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

lib/Frontend/ASTUnit.cpp
lib/Sema/SemaCodeComplete.cpp
test/Index/complete-preprocessor.m

index c6c710a67a580ff5186378353f445541a373b9b4..22476cae0aac4b6fbe20ceea64b91746acfa7304 100644 (file)
@@ -2256,7 +2256,6 @@ void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S,
     
     // Adjust priority based on similar type classes.
     unsigned Priority = C->Priority;
-    CXCursorKind CursorKind = C->Kind;
     CodeCompletionString *Completion = C->Completion;
     if (!Context.getPreferredType().isNull()) {
       if (C->Kind == CXCursor_MacroDefinition) {
@@ -2290,12 +2289,11 @@ void AugmentedCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &S,
       CodeCompletionBuilder Builder(getAllocator(), getCodeCompletionTUInfo(),
                                     CCP_CodePattern, C->Availability);
       Builder.AddTypedTextChunk(C->Completion->getTypedText());
-      CursorKind = CXCursor_NotImplemented;
       Priority = CCP_CodePattern;
       Completion = Builder.TakeString();
     }
     
-    AllResults.push_back(Result(Completion, Priority, CursorKind, 
+    AllResults.push_back(Result(Completion, Priority, C->Kind,
                                 C->Availability));
   }
   
index e065904271670d2c54542b5d013673c7ca62e6d7..1fc5d8f2cea5d360efe92be5881b40edea9f01f9 100644 (file)
@@ -7168,7 +7168,9 @@ void Sema::CodeCompletePreprocessorMacroName(bool IsDefinition) {
          M != MEnd; ++M) {
       Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
                                            M->first->getName()));
-      Results.AddResult(Builder.TakeString());
+      Results.AddResult(CodeCompletionResult(Builder.TakeString(),
+                                             CCP_CodePattern,
+                                             CXCursor_MacroDefinition));
     }
     Results.ExitScope();
   } else if (IsDefinition) {
index bea9d32d1a554ece54811c843ddf80bd7fd54fd0..baeb4e94562f07fe5a9c551ac0064bc6ded376cd 100644 (file)
@@ -53,8 +53,8 @@ FOO(in,t) value;
 // CHECK-CC2-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace  }{Placeholder macro} (40)
 // CHECK-CC2-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace  }{Placeholder message} (40)
 // RUN: c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: NotImplemented:{TypedText BAR} (40)
-// CHECK-CC3: NotImplemented:{TypedText FOO} (40)
+// CHECK-CC3: macro definition:{TypedText BAR} (40)
+// CHECK-CC3: macro definition:{TypedText FOO} (40)
 // RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: c-index-test -code-completion-at=%s:11:13 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // RUN: c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s