]> granicus.if.org Git - clang/commitdiff
Teach libclang how to visit the children of a C++ base-class specifier
authorDouglas Gregor <dgregor@apple.com>
Wed, 2 Mar 2011 19:17:03 +0000 (19:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 2 Mar 2011 19:17:03 +0000 (19:17 +0000)
(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

test/Index/annotate-nested-name-specifier.cpp
tools/libclang/CIndex.cpp

index b2f6a26e611fd341c5adaf203420ccae63d48fde..b315b7eb19959ca2c983fcec737ed775108a546d 100644 (file)
@@ -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]
index ad3f1df105d17c019a2d826ca6f25054f4b98a81..d29e459827763102035747bf248623bb99c5133c 100644 (file)
@@ -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;
 }