summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PreprocessingRecord.cpp6
-rw-r--r--clang/test/Index/getcursor-pp-pch.c9
-rw-r--r--clang/test/Index/getcursor-pp-pch.c.h1
-rw-r--r--clang/tools/libclang/CIndex.cpp6
4 files changed, 13 insertions, 9 deletions
diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp
index 2368b389810..3f288b0fd9f 100644
--- a/clang/lib/Lex/PreprocessingRecord.cpp
+++ b/clang/lib/Lex/PreprocessingRecord.cpp
@@ -145,10 +145,10 @@ unsigned PreprocessingRecord::findEndLocalPreprocessedEntity(
}
void PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) {
- SourceLocation Loc = Entity->getSourceRange().getBegin();
+ assert(Entity);
assert((PreprocessedEntities.empty() ||
- !SourceMgr.isBeforeInTranslationUnit(Loc,
- PreprocessedEntities.back()->getSourceRange().getEnd())) &&
+ !SourceMgr.isBeforeInTranslationUnit(Entity->getSourceRange().getBegin(),
+ PreprocessedEntities.back()->getSourceRange().getBegin())) &&
"Adding a preprocessed entity that is before the previous one in TU");
PreprocessedEntities.push_back(Entity);
}
diff --git a/clang/test/Index/getcursor-pp-pch.c b/clang/test/Index/getcursor-pp-pch.c
index dc597ffa94e..d68384c6606 100644
--- a/clang/test/Index/getcursor-pp-pch.c
+++ b/clang/test/Index/getcursor-pp-pch.c
@@ -11,6 +11,8 @@ void OBSCURE(func)(int x) {
// RUN: c-index-test -cursor-at=%s.h:1:11 \
// RUN: -cursor-at=%s.h:2:14 \
// RUN: -cursor-at=%s.h:4:5 \
+// RUN: -cursor-at=%s.h:5:5 \
+// RUN: -cursor-at=%s.h:5:14 \
// RUN: -cursor-at=%s:5:7 \
// RUN: -cursor-at=%s:6:6 \
// RUN: -cursor-at=%s:6:19 \
@@ -21,14 +23,21 @@ void OBSCURE(func)(int x) {
// RUN: c-index-test -cursor-at=%s.h:1:11 \
// RUN: -cursor-at=%s.h:2:14 \
// RUN: -cursor-at=%s.h:4:5 \
+// RUN: -cursor-at=%s.h:5:5 \
+// RUN: -cursor-at=%s.h:5:14 \
// RUN: -cursor-at=%s:5:7 \
// RUN: -cursor-at=%s:6:6 \
// RUN: -cursor-at=%s:6:19 \
// RUN: -include %t.h %s | FileCheck %s
+// From header
// CHECK: macro definition=OBSCURE
// CHECK: macro definition=DECORATION
// CHECK: macro expansion=DECORATION:2:9
// CHECK: macro expansion=OBSCURE:1:9
+// CHECK: macro expansion=DECORATION:2:9
+
+// From main file
+// CHECK: macro expansion=OBSCURE:1:9
// CHECK: macro expansion=OBSCURE:1:9
// CHECK: macro expansion=DECORATION:2:9
diff --git a/clang/test/Index/getcursor-pp-pch.c.h b/clang/test/Index/getcursor-pp-pch.c.h
index 184dd8b4104..c24a39c0e9d 100644
--- a/clang/test/Index/getcursor-pp-pch.c.h
+++ b/clang/test/Index/getcursor-pp-pch.c.h
@@ -2,3 +2,4 @@
#define DECORATION
DECORATION
+OBSCURE(DECORATION)
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 5916d5c3374..d9bc5ca2599 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3468,12 +3468,6 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
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;
}
OpenPOWER on IntegriCloud