} else if (const auto *FD = dyn_cast<FunctionDecl>(DeclNode)) {
if (FD->isDefaulted())
ScopedChildren = true;
+ if (FD->isTemplateInstantiation())
+ ScopedTraversal = true;
}
ASTNodeNotSpelledInSourceScope RAII1(this, ScopedTraversal);
TemplStruct() {}
~TemplStruct() {}
+ void outOfLine(T);
+
private:
T m_t;
};
template<typename T>
+void TemplStruct<T>::outOfLine(T)
+{
+
+}
+
+template<typename T>
T timesTwo(T input)
{
return input * 2;
hasTemplateArgument(0, refersToType(asString("float"))));
EXPECT_TRUE(matches(Code, traverse(TK_AsIs, MTempl)));
// TODO: If we could match on explicit instantiations of function templates,
- // this would be EXPECT_TRUE.
+ // this would be EXPECT_TRUE. See Sema::ActOnExplicitInstantiation.
EXPECT_FALSE(
matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, MTempl)));
}
EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
}
{
+ // Instantiated, out-of-line methods are not matchable.
+ auto M =
+ cxxMethodDecl(hasName("outOfLine"), isDefinition(),
+ hasParameter(0, parmVarDecl(hasType(asString("float")))));
+ EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+ EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+ }
+ {
// Explicit specialization is written in source and it matches:
auto M = classTemplateSpecializationDecl(
hasName("TemplStruct"),