diff --git a/test/Index/annotate-nested-name-specifier.cpp b/test/Index/annotate-nested-name-specifier.cpp index b2f6a26e61..b315b7eb19 100644 --- a/test/Index/annotate-nested-name-specifier.cpp +++ b/test/Index/annotate-nested-name-specifier.cpp @@ -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: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: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: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: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] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index ad3f1df105..d29e459827 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -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; }