aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-01-07 19:16:25 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-01-07 19:16:25 +0000
commit664b06f9bd2ea83443ddc8553feba8ba48880752 (patch)
tree32ee70458994744d3be3d967d541dfe84bea86ab /test
parent8169b671974fc15b6059b1e9532f7f3207d79786 (diff)
[libclang] When getting the cursor for an identifier inside a macro definition, check if
this was ever a macro name and return a specific CXCursor_MacroExpansion cursor in such a case, instead of the generic CXCursor_MacroDefinition. Checking for macro name makes sure the identifier is not part of the identifier list in a function macro. While, in general, resolving identifiers in macro definitions to other macros may not be completely accurate, it greatly improves functionality such as give-me-the-definition-of-this, which was not working at all inside macro definitions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Index/c-index-getCursor-pp.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/Index/c-index-getCursor-pp.c b/test/Index/c-index-getCursor-pp.c
index 48d07adf22..8efaaf26c1 100644
--- a/test/Index/c-index-getCursor-pp.c
+++ b/test/Index/c-index-getCursor-pp.c
@@ -1,6 +1,6 @@
#define OBSCURE(X) X
#define DECORATION
-
+#define FNM(X) OBSCURE(X)
typedef int T;
void OBSCURE(func)(int x) {
OBSCURE(T) DECORATION value;
@@ -23,6 +23,8 @@ const char *fname = __FILE__;
#if defined(OBSCURE)
#endif
+#define C(A) A
+
// RUN: c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
// CHECK-1: macro definition=OBSCURE
// RUN: c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
@@ -45,8 +47,17 @@ const char *fname = __FILE__;
// CHECK-10: 20:8 macro expansion=OBSCURE
// CHECK-10: 23:13 macro expansion=OBSCURE
+// RUN: c-index-test -cursor-at=%s:3:20 -cursor-at=%s:12:14 \
+// RUN: -cursor-at=%s:26:11 -cursor-at=%s:26:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-IN-MACRODEF %s
+// CHECK-IN-MACRODEF: 3:16 macro expansion=OBSCURE
+// CHECK-IN-MACRODEF: 12:14 macro expansion=A
+// CHECK-IN-MACRODEF: 26:9 macro definition=C
+// CHECK-IN-MACRODEF: 26:9 macro definition=C
+
// Same tests, but with "editing" optimizations
// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:5:7 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-3 %s
// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:3:20 -cursor-at=%s:12:14 \
+// RUN: -cursor-at=%s:26:11 -cursor-at=%s:26:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-IN-MACRODEF %s