[cfe-commits] r156522 - in /cfe/trunk: include/clang/AST/RecursiveASTVisitor.h unittests/Tooling/RecursiveASTVisitorTest.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Wed May 9 16:51:36 PDT 2012
Author: rsmith
Date: Wed May 9 18:51:36 2012
New Revision: 156522
URL: http://llvm.org/viewvc/llvm-project?rev=156522&view=rev
Log:
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!
Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=156522&r1=156521&r2=156522&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed May 9 18:51:36 2012
@@ -1451,10 +1451,11 @@
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:
Modified: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=156522&r1=156521&r2=156522&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp Wed May 9 18:51:36 2012
@@ -301,6 +301,19 @@
"}\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
More information about the cfe-commits
mailing list