diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-01-07 19:16:25 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-01-07 19:16:25 +0000 |
commit | 579825a50aad9759912f349fd9f52c8961056dd3 (patch) | |
tree | 4d422a1bf72d7cd1103b8e9bce377f8ffd4d0fb6 /clang/test/Index/c-index-getCursor-pp.c | |
parent | 7572be2e447b8b1762479a58b4dc3617db0ce120 (diff) | |
download | bcm5719-llvm-579825a50aad9759912f349fd9f52c8961056dd3.tar.gz bcm5719-llvm-579825a50aad9759912f349fd9f52c8961056dd3.zip |
[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.
llvm-svn: 171773
Diffstat (limited to 'clang/test/Index/c-index-getCursor-pp.c')
-rw-r--r-- | clang/test/Index/c-index-getCursor-pp.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/test/Index/c-index-getCursor-pp.c b/clang/test/Index/c-index-getCursor-pp.c index 48d07adf220..8efaaf26c13 100644 --- a/clang/test/Index/c-index-getCursor-pp.c +++ b/clang/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 |