diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-09 23:51:36 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-05-09 23:51:36 +0000 |
| commit | 6dd62fd99d6e2227de4adfc7429ed14ffca6f180 (patch) | |
| tree | fedb73c1f3571b3d11ac7973455459363c4f8067 /clang | |
| parent | 982205bcaeb92b00673008908fdb064fa7f3eedf (diff) | |
| download | bcm5719-llvm-6dd62fd99d6e2227de4adfc7429ed14ffca6f180.tar.gz bcm5719-llvm-6dd62fd99d6e2227de4adfc7429ed14ffca6f180.zip | |
RecursiveASTVisitor:
We don't create any declaration to mark the explicit instantiation of function
templates other than the instantiation itself, so visit that when traversing
the function template decl.
This is a temporary fix, pending the creation of a Decl node to represent the
explicit instantiation.
Patch by Daniel Jasper!
llvm-svn: 156522
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/RecursiveASTVisitor.h | 5 | ||||
| -rw-r--r-- | clang/unittests/Tooling/RecursiveASTVisitorTest.cpp | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index a9a98d77ba2..41a6d8f503d 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1451,10 +1451,11 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionInstantiations( TRY_TO(TraverseDecl(FD)); break; - // No need to visit explicit instantiations, we'll find the node - // eventually. + // FIXME: For now traverse explicit instantiations here. Change that + // once they are represented as dedicated nodes in the AST. case TSK_ExplicitInstantiationDeclaration: case TSK_ExplicitInstantiationDefinition: + TRY_TO(TraverseDecl(FD)); break; case TSK_ExplicitSpecialization: diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp index 953817e61fb..a26c9f3cb73 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp @@ -301,6 +301,19 @@ TEST(RecursiveASTVisitor, VisitsCallInPartialTemplateSpecialization) { "}\n")); } +TEST(RecursiveASTVisitor, VisitsExplicitTemplateSpecialization) { + CXXMemberCallVisitor Visitor; + Visitor.ExpectMatch("A::f", 4, 5); + EXPECT_TRUE(Visitor.runOver( + "struct A {\n" + " void f() const {}\n" + " template<class T> void g(const T& t) const {\n" + " t.f();\n" + " }\n" + "};\n" + "template void A::g(const A& a) const;\n")); +} + TEST(RecursiveASTVisitor, VisitsPartialTemplateSpecialization) { // From cfe-commits/Week-of-Mon-20100830/033998.html // Contrary to the approach sugggested in that email, we visit all |

