diff options
author | Nico Weber <nicolasweber@gmx.de> | 2016-01-22 15:11:54 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2016-01-22 15:11:54 +0000 |
commit | c4acee338097f7f2a6a70cdd38dc7eb1f97c040e (patch) | |
tree | 83dc24d9deaee4ab1af31446513c9b7dbed19ff9 /clang/unittests/Tooling/RecursiveASTVisitorTest.cpp | |
parent | 0ff939f251ff18774050d3170697bf61dfbc4dba (diff) | |
download | bcm5719-llvm-c4acee338097f7f2a6a70cdd38dc7eb1f97c040e.tar.gz bcm5719-llvm-c4acee338097f7f2a6a70cdd38dc7eb1f97c040e.zip |
Let RecursiveASTVisitor visit array index VarDecls
An implicit copy ctor creates loop VarDecls that hang off CXXCtorInitializer.
RecursiveASTVisitor used to not visit them, so that they didn't show up in the
parent map used by ASTMatchers, causing asserts() when the implicit
DeclRefExpr() in a CXXCtorInitializer referred to one of these VarDecls.
Fixes PR26227.
http://reviews.llvm.org/D16413
llvm-svn: 258503
Diffstat (limited to 'clang/unittests/Tooling/RecursiveASTVisitorTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/RecursiveASTVisitorTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp index 5d0e2bccd4d..991ae8bb7f3 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp @@ -133,4 +133,23 @@ TEST(RecursiveASTVisitor, AttributesAreVisited) { "};\n")); } +// Check to ensure that VarDecls are visited. +class VarDeclVisitor : public ExpectedLocationVisitor<VarDeclVisitor> { +public: + bool VisitVarDecl(VarDecl *VD) { + Match(VD->getNameAsString(), VD->getLocStart()); + return true; + } +}; + +TEST(RecursiveASTVisitor, ArrayInitializersAreVisited) { + VarDeclVisitor Visitor; + Visitor.ExpectMatch("__i0", 1, 8); + EXPECT_TRUE( + Visitor.runOver("struct MyClass {\n" + " int c[1];\n" + " static MyClass Create() { return MyClass(); }\n" + "};\n")); +} + } // end anonymous namespace |