]> granicus.if.org Git - clang/commitdiff
Fix AST-matcher descendant visiting for Types, TypeLocs and NestedNamespecifierLocs.
authorDaniel Jasper <djasper@google.com>
Tue, 13 Nov 2012 17:14:11 +0000 (17:14 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 13 Nov 2012 17:14:11 +0000 (17:14 +0000)
The RecursiveASTVisitor assumes that any given Traverse-method can be called with a NULL-node. So the subclass needs to handle these appropriately.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167850 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ASTMatchers/ASTMatchFinder.cpp

index 8ecb26e8c19d37c61f54c3e6ba9d9c175ffc8053..6ff125bc8358b436e597d702f159eb864746bc8f 100644 (file)
@@ -183,6 +183,8 @@ public:
   // We assume that the QualType and the contained type are on the same
   // hierarchy level. Thus, we try to match either of them.
   bool TraverseType(QualType TypeNode) {
+    if (TypeNode.isNull())
+      return true;
     ScopedIncrement ScopedDepth(&CurrentDepth);
     // Match the Type.
     if (!match(*TypeNode))
@@ -193,6 +195,8 @@ public:
   // We assume that the TypeLoc, contained QualType and contained Type all are
   // on the same hierarchy level. Thus, we try to match all of them.
   bool TraverseTypeLoc(TypeLoc TypeLocNode) {
+    if (TypeLocNode.isNull())
+      return true;
     ScopedIncrement ScopedDepth(&CurrentDepth);
     // Match the Type.
     if (!match(*TypeLocNode.getType()))
@@ -208,10 +212,12 @@ public:
     return (NNS == NULL) || traverse(*NNS);
   }
   bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
+    if (!NNS)
+      return true;
     ScopedIncrement ScopedDepth(&CurrentDepth);
     if (!match(*NNS.getNestedNameSpecifier()))
       return false;
-    return !NNS || traverse(NNS);
+    return traverse(NNS);
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }