зеркало из https://github.com/microsoft/clang.git
[libclang] When pointing at a macro expansion inside a macro argument,
return a cursor for the inner macro. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140207 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
ef70724e66
Коммит
2502efd261
|
@ -145,10 +145,10 @@ unsigned PreprocessingRecord::findEndLocalPreprocessedEntity(
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) {
|
void PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) {
|
||||||
SourceLocation Loc = Entity->getSourceRange().getBegin();
|
assert(Entity);
|
||||||
assert((PreprocessedEntities.empty() ||
|
assert((PreprocessedEntities.empty() ||
|
||||||
!SourceMgr.isBeforeInTranslationUnit(Loc,
|
!SourceMgr.isBeforeInTranslationUnit(Entity->getSourceRange().getBegin(),
|
||||||
PreprocessedEntities.back()->getSourceRange().getEnd())) &&
|
PreprocessedEntities.back()->getSourceRange().getBegin())) &&
|
||||||
"Adding a preprocessed entity that is before the previous one in TU");
|
"Adding a preprocessed entity that is before the previous one in TU");
|
||||||
PreprocessedEntities.push_back(Entity);
|
PreprocessedEntities.push_back(Entity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ void OBSCURE(func)(int x) {
|
||||||
// RUN: c-index-test -cursor-at=%s.h:1:11 \
|
// RUN: c-index-test -cursor-at=%s.h:1:11 \
|
||||||
// RUN: -cursor-at=%s.h:2:14 \
|
// RUN: -cursor-at=%s.h:2:14 \
|
||||||
// RUN: -cursor-at=%s.h:4:5 \
|
// 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:5:7 \
|
||||||
// RUN: -cursor-at=%s:6:6 \
|
// RUN: -cursor-at=%s:6:6 \
|
||||||
// RUN: -cursor-at=%s:6:19 \
|
// 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: c-index-test -cursor-at=%s.h:1:11 \
|
||||||
// RUN: -cursor-at=%s.h:2:14 \
|
// RUN: -cursor-at=%s.h:2:14 \
|
||||||
// RUN: -cursor-at=%s.h:4:5 \
|
// 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:5:7 \
|
||||||
// RUN: -cursor-at=%s:6:6 \
|
// RUN: -cursor-at=%s:6:6 \
|
||||||
// RUN: -cursor-at=%s:6:19 \
|
// RUN: -cursor-at=%s:6:19 \
|
||||||
// RUN: -include %t.h %s | FileCheck %s
|
// RUN: -include %t.h %s | FileCheck %s
|
||||||
|
|
||||||
|
// From header
|
||||||
// CHECK: macro definition=OBSCURE
|
// CHECK: macro definition=OBSCURE
|
||||||
// CHECK: macro definition=DECORATION
|
// CHECK: macro definition=DECORATION
|
||||||
// CHECK: macro expansion=DECORATION:2:9
|
// CHECK: macro expansion=DECORATION:2:9
|
||||||
// CHECK: macro expansion=OBSCURE:1: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=OBSCURE:1:9
|
||||||
// CHECK: macro expansion=DECORATION:2:9
|
// CHECK: macro expansion=DECORATION:2:9
|
||||||
|
|
|
@ -2,3 +2,4 @@
|
||||||
#define DECORATION
|
#define DECORATION
|
||||||
|
|
||||||
DECORATION
|
DECORATION
|
||||||
|
OBSCURE(DECORATION)
|
||||||
|
|
|
@ -3468,12 +3468,6 @@ static enum CXChildVisitResult GetCursorVisitor(CXCursor cursor,
|
||||||
cursor.kind == CXCursor_TypeRef)
|
cursor.kind == CXCursor_TypeRef)
|
||||||
return CXChildVisit_Recurse;
|
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;
|
*BestCursor = cursor;
|
||||||
return CXChildVisit_Recurse;
|
return CXChildVisit_Recurse;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче