return functionTemplateDecl(hasName("f"));
}
};
+struct GetVarTemplPattern {
+ using DeclTy = VarTemplateDecl;
+ BindableMatcher<Decl> operator()() {
+ return namedDecl(hasName("v"), has(templateTypeParmDecl()));
+ }
+};
struct GetClassTemplPattern {
using DeclTy = ClassTemplateDecl;
BindableMatcher<Decl> operator()() { return classTemplateDecl(hasName("X")); }
const auto *ExternFT = "template <class> void f();";
const auto *StaticFT = "template <class> static void f();";
const auto *AnonFT = "namespace { template <class> void f(); }";
+// VarTemplateDecl:
+const auto *ExternVT = "template <class> extern int v;";
+const auto *StaticVT = "template <class> static int v;";
+const auto *AnonVT = "namespace { template <class> extern int v; }";
// ClassTemplateDecl:
const auto *ExternCT = "template <class> class X;";
const auto *AnonCT = "namespace { template <class> class X; }";
using ImportScopedEnumsVisibilityChain = ImportVisibilityChain<GetEnumPattern>;
using ImportFunctionTemplatesVisibilityChain =
ImportVisibilityChain<GetFunTemplPattern>;
+using ImportVariableTemplatesVisibilityChain =
+ ImportVisibilityChain<GetVarTemplPattern>;
using ImportClassTemplatesVisibilityChain =
ImportVisibilityChain<GetClassTemplPattern>;
TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
TypedTest_ImportChain();
}
+// Value-parameterized test for variable templates.
+TEST_P(ImportVariableTemplatesVisibilityChain, ImportChain) {
+ TypedTest_ImportChain();
+}
// Value-parameterized test for class templates.
TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
TypedTest_ImportChain();
::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternFT, StaticFT,
AnonFT)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests,
+ ImportVariableTemplatesVisibilityChain,
+ ::testing::Combine(DefaultTestValuesForRunOptions,
+ ::testing::Values(ExternVT,
+ AnonVT)), );
INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternCT,
using ImportScopedEnumsVisibility = ImportVisibility<GetEnumPattern>;
using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>;
using ImportFunctionTemplatesVisibility = ImportVisibility<GetFunTemplPattern>;
+using ImportVariableTemplatesVisibility = ImportVisibility<GetVarTemplPattern>;
using ImportClassTemplatesVisibility = ImportVisibility<GetClassTemplPattern>;
// FunctionDecl.
TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
TypedTest_ImportAfterImport();
}
+// VarTemplateDecl.
+TEST_P(ImportVariableTemplatesVisibility, ImportAfter) {
+ TypedTest_ImportAfter();
+}
+TEST_P(ImportVariableTemplatesVisibility, ImportAfterImport) {
+ TypedTest_ImportAfterImport();
+}
// ClassTemplateDecl.
TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
INSTANTIATE_TEST_CASE_P(
+ ParameterizedTests, ImportVariableTemplatesVisibility,
+ ::testing::Combine(
+ DefaultTestValuesForRunOptions,
+ ::testing::Values(
+ std::make_tuple(ExternVT, ExternVT, ExpectLinkedDeclChain),
+ std::make_tuple(ExternVT, StaticVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(ExternVT, AnonVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(StaticVT, ExternVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(StaticVT, StaticVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(StaticVT, AnonVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(AnonVT, ExternVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(AnonVT, StaticVT, ExpectUnlinkedDeclChain),
+ std::make_tuple(AnonVT, AnonVT, ExpectUnlinkedDeclChain))), );
+INSTANTIATE_TEST_CASE_P(
ParameterizedTests, ImportClassTemplatesVisibility,
::testing::Combine(
DefaultTestValuesForRunOptions,