summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/ASTMatchFinder.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-11-13 17:14:11 +0000
committerDaniel Jasper <djasper@google.com>2012-11-13 17:14:11 +0000
commita05bb6bd7016c4e43d1dca4bcd969cb245d2ad43 (patch)
tree303660a12381fc3f6c77bcc530cf8d73ff2468d0 /clang/lib/ASTMatchers/ASTMatchFinder.cpp
parent379574fd20cb9ac83f126f9a6111f202f5120c71 (diff)
downloadbcm5719-llvm-a05bb6bd7016c4e43d1dca4bcd969cb245d2ad43.tar.gz
bcm5719-llvm-a05bb6bd7016c4e43d1dca4bcd969cb245d2ad43.zip
Fix AST-matcher descendant visiting for Types, TypeLocs and NestedNamespecifierLocs.
The RecursiveASTVisitor assumes that any given Traverse-method can be called with a NULL-node. So the subclass needs to handle these appropriately. llvm-svn: 167850
Diffstat (limited to 'clang/lib/ASTMatchers/ASTMatchFinder.cpp')
-rw-r--r--clang/lib/ASTMatchers/ASTMatchFinder.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index 8ecb26e8c19..6ff125bc835 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -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; }
OpenPOWER on IntegriCloud