[cfe-commits] r100431 - in /cfe/trunk: lib/Sema/CodeCompleteConsumer.cpp test/Index/complete-macros.c tools/CIndex/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Mon Apr 5 09:10:30 PDT 2010
Author: dgregor
Date: Mon Apr 5 11:10:30 2010
New Revision: 100431
URL: http://llvm.org/viewvc/llvm-project?rev=100431&view=rev
Log:
Code completion results that refer to macros now get the cursor kind
of macro definitions when passed to CIndex. Add test for code
completion of macros via CIndex.
Added:
cfe/trunk/test/Index/complete-macros.c
Modified:
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/tools/CIndex/CIndex.cpp
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=100431&r1=100430&r2=100431&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Mon Apr 5 11:10:30 2010
@@ -582,9 +582,12 @@
break;
}
break;
-
- case Result::RK_Keyword:
+
case Result::RK_Macro:
+ Kind = CXCursor_MacroDefinition;
+ break;
+
+ case Result::RK_Keyword:
case Result::RK_Pattern:
Kind = CXCursor_NotImplemented;
break;
Added: cfe/trunk/test/Index/complete-macros.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-macros.c?rev=100431&view=auto
==============================================================================
--- cfe/trunk/test/Index/complete-macros.c (added)
+++ cfe/trunk/test/Index/complete-macros.c Mon Apr 5 11:10:30 2010
@@ -0,0 +1,11 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+#define FOO(Arg1,Arg2) foobar
+
+void f() {
+
+}
+
+// RUN: c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: macro definition:{TypedText FOO}{LeftParen (}{Placeholder Arg1}{Comma , }{Placeholder Arg2}{RightParen )}
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=100431&r1=100430&r2=100431&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Mon Apr 5 11:10:30 2010
@@ -2333,7 +2333,7 @@
RegionOfInterest.setBegin(
cxloc::translateSourceLocation(clang_getTokenLocation(TU, Tokens[0])));
SourceLocation End
- = cxloc::translateSourceLocation(clang_getTokenLocation(TU,
+ = cxloc::translateSourceLocation(clang_getTokenLocation(TU,
Tokens[NumTokens - 1]));
RegionOfInterest.setEnd(CXXUnit->getPreprocessor().getLocForEndOfToken(End));
More information about the cfe-commits
mailing list