[llvm-branch-commits] [cfe-branch] r121571 - in /cfe/branches/Apple/whitney: test/Index/c-index-getCursor-pp.c tools/libclang/CIndex.cpp

Daniel Dunbar daniel at zuster.org
Fri Dec 10 13:38:38 PST 2010


Author: ddunbar
Date: Fri Dec 10 15:38:38 2010
New Revision: 121571

URL: http://llvm.org/viewvc/llvm-project?rev=121571&view=rev
Log:
Merge r121470:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Fri Dec 10 07:23:11 2010 +0000

    In clang_getCursor(), don't override a preprocessing cursor within
    another preprocessing cursor, since we want the outermost one.

Modified:
    cfe/branches/Apple/whitney/test/Index/c-index-getCursor-pp.c
    cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp

Modified: cfe/branches/Apple/whitney/test/Index/c-index-getCursor-pp.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Index/c-index-getCursor-pp.c?rev=121571&r1=121570&r2=121571&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/Index/c-index-getCursor-pp.c (original)
+++ cfe/branches/Apple/whitney/test/Index/c-index-getCursor-pp.c Fri Dec 10 15:38:38 2010
@@ -8,6 +8,11 @@
 
 #include "a.h"
 
+#define A(X) X
+#define B(X) A(X)
+
+B(int x);
+
 // 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
@@ -20,6 +25,8 @@
 // CHECK-5: macro instantiation=DECORATION:2:9
 // RUN: c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
 // CHECK-6: inclusion directive=a.h
+// RUN: c-index-test -cursor-at=%s:14:1 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-7 %s
+// CHECK-7: macro instantiation=B:12:9
 
 // 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

Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=121571&r1=121570&r2=121571&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Fri Dec 10 15:38:38 2010
@@ -3069,6 +3069,12 @@
       cursor.kind == CXCursor_TypeRef)
     return CXChildVisit_Recurse;
   
+  // Don't override a preprocessing cursor with another preprocessing
+  // cursor; we want the outermost preprocessing cursor.
+  if (clang_isPreprocessing(cursor.kind) &&
+      clang_isPreprocessing(BestCursor->kind))
+    return CXChildVisit_Recurse;
+  
   *BestCursor = cursor;
   return CXChildVisit_Recurse;
 }





More information about the llvm-branch-commits mailing list