diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-09-11 02:17:21 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-09-11 02:17:21 +0000 |
commit | 59cabd7101d3871519019efdff008378a985dae9 (patch) | |
tree | 281940f42c0d27926bd063320881dd8f16f93a7b | |
parent | 85f90bd579ee83d3061715ad0dcb7575832e4fe9 (diff) |
[libclang] Fix getting a cursor inside an angled #include directive.
Fixed by pointing the end location of the preprocessed entity for the #include
at the closing '>', instead of the start of '<'.
rdar://11113134
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163588 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 3 | ||||
-rw-r--r-- | test/Index/c-index-getCursor-pp.c | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 738bed36ba..70302f10ae 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1296,6 +1296,9 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, case tok::string_literal: Filename = getSpelling(FilenameTok, FilenameBuffer); End = FilenameTok.getLocation(); + // For an angled include, point the end location at the closing '>'. + if (FilenameTok.is(tok::angle_string_literal)) + End = End.getLocWithOffset(Filename.size()-1); CharEnd = End.getLocWithOffset(Filename.size()); break; diff --git a/test/Index/c-index-getCursor-pp.c b/test/Index/c-index-getCursor-pp.c index 0a10450af5..01b0a6972e 100644 --- a/test/Index/c-index-getCursor-pp.c +++ b/test/Index/c-index-getCursor-pp.c @@ -15,6 +15,8 @@ B(int x); const char *fname = __FILE__; +#include <a.h> + // 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 @@ -31,6 +33,8 @@ const char *fname = __FILE__; // CHECK-7: macro expansion=B:12:9 // RUN: c-index-test -cursor-at=%s:16:25 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-8 %s // CHECK-8: macro expansion=__FILE__ +// RUN: c-index-test -cursor-at=%s:18:12 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-9 %s +// CHECK-9: inclusion directive=a.h // 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 |