[cfe-commits] r163588 - in /cfe/trunk: lib/Lex/PPDirectives.cpp test/Index/c-index-getCursor-pp.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Mon Sep 10 19:17:21 PDT 2012


Author: akirtzidis
Date: Mon Sep 10 21:17:21 2012
New Revision: 163588

URL: http://llvm.org/viewvc/llvm-project?rev=163588&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/test/Index/c-index-getCursor-pp.c

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=163588&r1=163587&r2=163588&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Sep 10 21:17:21 2012
@@ -1296,6 +1296,9 @@
   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;
 

Modified: cfe/trunk/test/Index/c-index-getCursor-pp.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-getCursor-pp.c?rev=163588&r1=163587&r2=163588&view=diff
==============================================================================
--- cfe/trunk/test/Index/c-index-getCursor-pp.c (original)
+++ cfe/trunk/test/Index/c-index-getCursor-pp.c Mon Sep 10 21:17:21 2012
@@ -15,6 +15,8 @@
 
 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 @@
 // 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





More information about the cfe-commits mailing list