// TypeLoc never has a deduced type. https://llvm.org/PR42914
Outer.add(DT->getDeducedType(), Flags | Rel::Underlying);
}
+ void VisitDeducedTemplateSpecializationType(
+ const DeducedTemplateSpecializationType *DTST) {
+ // FIXME: This is a workaround for https://llvm.org/PR42914,
+ // which is causing DTST->getDeducedType() to be empty. We
+ // fall back to the template pattern and miss the instantiation
+ // even when it's known in principle. Once that bug is fixed,
+ // this method can be removed (the existing handling in
+ // VisitDeducedType() is sufficient).
+ if (auto *TD = DTST->getTemplateName().getAsTemplateDecl())
+ Outer.add(TD->getTemplatedDecl(), Flags | Rel::TemplatePattern);
+ }
void VisitTypedefType(const TypedefType *TT) {
Outer.add(TT->getDecl(), Flags);
}
EXPECT_DECLS("TemplateSpecializationTypeLoc",
{"template<> class Foo<int *>", Rel::TemplateInstantiation},
{"template <typename T> class Foo<T *>", Rel::TemplatePattern});
+
+ Code = R"cpp(
+ // Class template argument deduction
+ template <typename T>
+ struct Test {
+ Test(T);
+ };
+ void foo() {
+ [[Test]] a(5);
+ }
+ )cpp";
+ Flags.push_back("-std=c++17");
+ EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
+ {"struct Test", Rel::TemplatePattern});
}
TEST_F(TargetDeclTest, FunctionTemplate) {
// FIXME: Auto-completion in a template requires disabling delayed template
// parsing.
TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+ TU.ExtraArgs.push_back("-std=c++17");
auto AST = TU.build();
};
)cpp",
"0: targets = {size}, decl\n"
- "1: targets = {E}\n"}};
+ "1: targets = {E}\n"},
+ // Class template argument deduction
+ {
+ R"cpp(
+ template <typename T>
+ struct Test {
+ Test(T);
+ };
+ void foo() {
+ $0^Test $1^a(5);
+ }
+ )cpp",
+ "0: targets = {Test}\n"
+ "1: targets = {a}, decl\n"}};
for (const auto &C : Cases) {
llvm::StringRef ExpectedCode = C.first;