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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121470 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index a74a7a9..d9aec47 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -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;
 }