Teach libclang how to visit the children of a C++ base-class specifier

(i.e., the TypeLoc describing the base class type).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126861 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2011-03-02 19:17:03 +00:00
Родитель 810b07ccf7
Коммит c314aa4845
2 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -135,7 +135,18 @@ struct X7 {
// CHECK: Punctuation: "::" [14:25 - 14:27] UsingDeclaration=vector[4:12]
// CHECK: Identifier: "vector" [14:27 - 14:33] OverloadedDeclRef=vector[4:12]
// CHECK: Punctuation: ";" [14:33 - 14:34]
// FIXME: Base specifiers, too
// Base specifiers
// CHECK: Identifier: "outer_alias" [16:19 - 16:30] NamespaceRef=outer_alias:10:11
// CHECK: Punctuation: "::" [16:30 - 16:32] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Identifier: "inner" [16:32 - 16:37] NamespaceRef=inner:2:13
// CHECK: Punctuation: "::" [16:37 - 16:39] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Identifier: "vector" [16:39 - 16:45] TemplateRef=vector:4:12
// CHECK: Punctuation: "<" [16:45 - 16:46] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Identifier: "X" [16:46 - 16:47] TypeRef=struct X:12:8
// CHECK: Punctuation: ">" [16:47 - 16:48] C++ base class specifier=outer_alias::inner::outer_alias::inner::vector<struct X>:4:12 [access=public isVirtual=false]
// CHECK: Keyword: "using" [17:3 - 17:8] UsingDeclaration=iterator[5:18]
// CHECK: Identifier: "outer_alias" [17:9 - 17:20] NamespaceRef=outer_alias:10:11
// CHECK: Punctuation: "::" [17:20 - 17:22] UsingDeclaration=iterator[5:18]

Просмотреть файл

@ -476,7 +476,8 @@ CursorVisitor::getPreprocessedEntities() {
/// \returns true if the visitation should be aborted, false if it
/// should continue.
bool CursorVisitor::VisitChildren(CXCursor Cursor) {
if (clang_isReference(Cursor.kind)) {
if (clang_isReference(Cursor.kind) &&
Cursor.kind != CXCursor_CXXBaseSpecifier) {
// By definition, references have no children.
return false;
}
@ -542,6 +543,14 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) {
return false;
}
if (Cursor.kind == CXCursor_CXXBaseSpecifier) {
if (CXXBaseSpecifier *Base = getCursorCXXBaseSpecifier(Cursor)) {
if (TypeSourceInfo *BaseTSInfo = Base->getTypeSourceInfo()) {
return Visit(BaseTSInfo->getTypeLoc());
}
}
}
// Nothing to visit at the moment.
return false;
}