blob: 262402415658f6bbca9e056eea60293fadf4aa25 [file] [log] [blame]
Gabor Marton3c72fe12019-05-13 10:06:25 +00001//===- unittest/AST/ASTImporterTest.cpp - AST node import test ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Type-parameterized tests for the correct import of Decls with different
10// visibility.
11//
12//===----------------------------------------------------------------------===//
13
14// Define this to have ::testing::Combine available.
15// FIXME: Better solution for this?
16#define GTEST_HAS_COMBINE 1
17
18#include "ASTImporterFixtures.h"
19
20namespace clang {
21namespace ast_matchers {
22
23using internal::BindableMatcher;
24
25// Type parameters for type-parameterized test fixtures.
26struct GetFunPattern {
27 using DeclTy = FunctionDecl;
28 BindableMatcher<Decl> operator()() { return functionDecl(hasName("f")); }
29};
30struct GetVarPattern {
31 using DeclTy = VarDecl;
32 BindableMatcher<Decl> operator()() { return varDecl(hasName("v")); }
33};
Balazs Keric8272192019-05-27 09:36:00 +000034struct GetClassPattern {
35 using DeclTy = CXXRecordDecl;
36 BindableMatcher<Decl> operator()() { return cxxRecordDecl(hasName("X")); }
37};
Balazs Kerieb79b252019-07-09 11:08:18 +000038struct GetEnumPattern {
39 using DeclTy = EnumDecl;
40 BindableMatcher<Decl> operator()() { return enumDecl(hasName("E")); }
41};
Balazs Keric86d47b2019-09-04 14:12:18 +000042struct GetTypedefNamePattern {
43 using DeclTy = TypedefNameDecl;
44 BindableMatcher<Decl> operator()() { return typedefNameDecl(hasName("T")); }
45};
Balazs Kerif8a89c82019-09-13 08:03:49 +000046struct GetFunTemplPattern {
47 using DeclTy = FunctionTemplateDecl;
48 BindableMatcher<Decl> operator()() {
49 return functionTemplateDecl(hasName("f"));
50 }
51};
Balázs Kéri8d67bcf2020-03-09 11:01:48 +010052struct GetVarTemplPattern {
53 using DeclTy = VarTemplateDecl;
54 BindableMatcher<Decl> operator()() {
55 return namedDecl(hasName("v"), has(templateTypeParmDecl()));
56 }
57};
Balázs Kéric2f6efc2019-11-15 15:05:20 +010058struct GetClassTemplPattern {
59 using DeclTy = ClassTemplateDecl;
60 BindableMatcher<Decl> operator()() { return classTemplateDecl(hasName("X")); }
61};
Gabor Marton3c72fe12019-05-13 10:06:25 +000062
63// Values for the value-parameterized test fixtures.
64// FunctionDecl:
65const auto *ExternF = "void f();";
66const auto *StaticF = "static void f();";
67const auto *AnonF = "namespace { void f(); }";
68// VarDecl:
69const auto *ExternV = "extern int v;";
70const auto *StaticV = "static int v;";
71const auto *AnonV = "namespace { extern int v; }";
Balazs Keric8272192019-05-27 09:36:00 +000072// CXXRecordDecl:
73const auto *ExternC = "class X;";
74const auto *AnonC = "namespace { class X; }";
Balazs Kerieb79b252019-07-09 11:08:18 +000075// EnumDecl:
76const auto *ExternE = "enum E {};";
77const auto *AnonE = "namespace { enum E {}; }";
Balázs Kérid4741c42020-02-17 14:25:16 +010078const auto *ExternEC = "enum class E;";
79const auto *AnonEC = "namespace { enum class E; }";
Balazs Keric86d47b2019-09-04 14:12:18 +000080// TypedefNameDecl:
81const auto *ExternTypedef = "typedef int T;";
82const auto *AnonTypedef = "namespace { typedef int T; }";
83const auto *ExternUsing = "using T = int;";
84const auto *AnonUsing = "namespace { using T = int; }";
Balazs Kerif8a89c82019-09-13 08:03:49 +000085// FunctionTemplateDecl:
86const auto *ExternFT = "template <class> void f();";
87const auto *StaticFT = "template <class> static void f();";
88const auto *AnonFT = "namespace { template <class> void f(); }";
Balázs Kéri8d67bcf2020-03-09 11:01:48 +010089// VarTemplateDecl:
90const auto *ExternVT = "template <class> extern int v;";
91const auto *StaticVT = "template <class> static int v;";
92const auto *AnonVT = "namespace { template <class> extern int v; }";
Balázs Kéric2f6efc2019-11-15 15:05:20 +010093// ClassTemplateDecl:
94const auto *ExternCT = "template <class> class X;";
95const auto *AnonCT = "namespace { template <class> class X; }";
Gabor Marton3c72fe12019-05-13 10:06:25 +000096
97// First value in tuple: Compile options.
98// Second value in tuple: Source code to be used in the test.
Dmitri Gribenkod4ef6542020-05-29 14:12:51 +020099using ImportVisibilityChainParams = ::testing::WithParamInterface<
100 std::tuple<std::vector<std::string>, const char *>>;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000101// Fixture to test the redecl chain of Decls with the same visibility. Gtest
102// makes it possible to have either value-parameterized or type-parameterized
103// fixtures. However, we cannot have both value- and type-parameterized test
104// fixtures. This is a value-parameterized test fixture in the gtest sense. We
105// intend to mimic gtest's type-parameters via the PatternFactory template
106// parameter. We manually instantiate the different tests with the each types.
107template <typename PatternFactory>
108class ImportVisibilityChain
109 : public ASTImporterTestBase, public ImportVisibilityChainParams {
110protected:
111 using DeclTy = typename PatternFactory::DeclTy;
Dmitri Gribenkod4ef6542020-05-29 14:12:51 +0200112 std::vector<std::string> getExtraArgs() const override {
113 return std::get<0>(GetParam());
114 }
Gabor Marton3c72fe12019-05-13 10:06:25 +0000115 std::string getCode() const { return std::get<1>(GetParam()); }
116 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
117
118 // Type-parameterized test.
119 void TypedTest_ImportChain() {
120 std::string Code = getCode() + getCode();
121 auto Pattern = getPattern();
122
Balazs Keri14d115f2019-07-15 12:16:30 +0000123 TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX14, "input0.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000124
125 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu, Pattern);
126 auto *FromD1 = LastDeclMatcher<DeclTy>().match(FromTu, Pattern);
127
Balazs Keri14d115f2019-07-15 12:16:30 +0000128 auto *ToD0 = Import(FromD0, Lang_CXX14);
129 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000130
131 EXPECT_TRUE(ToD0);
132 ASSERT_TRUE(ToD1);
133 EXPECT_NE(ToD0, ToD1);
134 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
135 }
136};
137
138// Manual instantiation of the fixture with each type.
139using ImportFunctionsVisibilityChain = ImportVisibilityChain<GetFunPattern>;
140using ImportVariablesVisibilityChain = ImportVisibilityChain<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000141using ImportClassesVisibilityChain = ImportVisibilityChain<GetClassPattern>;
Balázs Kérid4741c42020-02-17 14:25:16 +0100142using ImportScopedEnumsVisibilityChain = ImportVisibilityChain<GetEnumPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000143using ImportFunctionTemplatesVisibilityChain =
144 ImportVisibilityChain<GetFunTemplPattern>;
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100145using ImportVariableTemplatesVisibilityChain =
146 ImportVisibilityChain<GetVarTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100147using ImportClassTemplatesVisibilityChain =
148 ImportVisibilityChain<GetClassTemplPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000149
Balazs Keric8272192019-05-27 09:36:00 +0000150// Value-parameterized test for functions.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000151TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
152 TypedTest_ImportChain();
153}
Balazs Keric8272192019-05-27 09:36:00 +0000154// Value-parameterized test for variables.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000155TEST_P(ImportVariablesVisibilityChain, ImportChain) {
156 TypedTest_ImportChain();
157}
Balazs Keric8272192019-05-27 09:36:00 +0000158// Value-parameterized test for classes.
159TEST_P(ImportClassesVisibilityChain, ImportChain) {
160 TypedTest_ImportChain();
161}
Balázs Kérid4741c42020-02-17 14:25:16 +0100162// Value-parameterized test for scoped enums.
163TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
164 TypedTest_ImportChain();
165}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000166// Value-parameterized test for function templates.
167TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
168 TypedTest_ImportChain();
169}
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100170// Value-parameterized test for variable templates.
171TEST_P(ImportVariableTemplatesVisibilityChain, ImportChain) {
172 TypedTest_ImportChain();
173}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100174// Value-parameterized test for class templates.
175TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
176 TypedTest_ImportChain();
177}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000178
179// Automatic instantiation of the value-parameterized tests.
180INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
181 ::testing::Combine(
182 DefaultTestValuesForRunOptions,
183 ::testing::Values(ExternF, StaticF, AnonF)), );
184INSTANTIATE_TEST_CASE_P(
185 ParameterizedTests, ImportVariablesVisibilityChain,
186 ::testing::Combine(
187 DefaultTestValuesForRunOptions,
188 // There is no point to instantiate with StaticV, because in C++ we can
189 // forward declare a variable only with the 'extern' keyword.
190 // Consequently, each fwd declared variable has external linkage. This
191 // is different in the C language where any declaration without an
192 // initializer is a tentative definition, subsequent definitions may be
193 // provided but they must have the same linkage. See also the test
194 // ImportVariableChainInC which test for this special C Lang case.
195 ::testing::Values(ExternV, AnonV)), );
Balazs Keric8272192019-05-27 09:36:00 +0000196INSTANTIATE_TEST_CASE_P(
197 ParameterizedTests, ImportClassesVisibilityChain,
198 ::testing::Combine(
199 DefaultTestValuesForRunOptions,
200 ::testing::Values(ExternC, AnonC)), );
Balázs Kérid4741c42020-02-17 14:25:16 +0100201INSTANTIATE_TEST_CASE_P(
202 ParameterizedTests, ImportScopedEnumsVisibilityChain,
203 ::testing::Combine(
204 DefaultTestValuesForRunOptions,
205 ::testing::Values(ExternEC, AnonEC)), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000206INSTANTIATE_TEST_CASE_P(ParameterizedTests,
207 ImportFunctionTemplatesVisibilityChain,
208 ::testing::Combine(DefaultTestValuesForRunOptions,
209 ::testing::Values(ExternFT, StaticFT,
210 AnonFT)), );
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100211INSTANTIATE_TEST_CASE_P(ParameterizedTests,
212 ImportVariableTemplatesVisibilityChain,
213 ::testing::Combine(DefaultTestValuesForRunOptions,
214 ::testing::Values(ExternVT,
215 AnonVT)), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100216INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
217 ::testing::Combine(DefaultTestValuesForRunOptions,
218 ::testing::Values(ExternCT,
219 AnonCT)), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000220
221// First value in tuple: Compile options.
222// Second value in tuple: Tuple with informations for the test.
223// Code for first import (or initial code), code to import, whether the `f`
224// functions are expected to be linked in a declaration chain.
225// One value of this tuple is combined with every value of compile options.
226// The test can have a single tuple as parameter only.
Dmitri Gribenkod4ef6542020-05-29 14:12:51 +0200227using ImportVisibilityParams = ::testing::WithParamInterface<std::tuple<
228 std::vector<std::string>, std::tuple<const char *, const char *, bool>>>;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000229
230template <typename PatternFactory>
231class ImportVisibility
232 : public ASTImporterTestBase,
233 public ImportVisibilityParams {
234protected:
235 using DeclTy = typename PatternFactory::DeclTy;
Dmitri Gribenkod4ef6542020-05-29 14:12:51 +0200236 std::vector<std::string> getExtraArgs() const override {
237 return std::get<0>(GetParam());
238 }
Gabor Marton3c72fe12019-05-13 10:06:25 +0000239 std::string getCode0() const { return std::get<0>(std::get<1>(GetParam())); }
240 std::string getCode1() const { return std::get<1>(std::get<1>(GetParam())); }
241 bool shouldBeLinked() const { return std::get<2>(std::get<1>(GetParam())); }
242 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
243
244 void TypedTest_ImportAfter() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000245 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
246 TranslationUnitDecl *FromTu =
247 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000248
249 auto *ToD0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
250 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
251
Balazs Keri14d115f2019-07-15 12:16:30 +0000252 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000253
254 ASSERT_TRUE(ToD0);
255 ASSERT_TRUE(ToD1);
256 EXPECT_NE(ToD0, ToD1);
257
258 if (shouldBeLinked())
259 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
260 else
261 EXPECT_FALSE(ToD1->getPreviousDecl());
262 }
263
264 void TypedTest_ImportAfterImport() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000265 TranslationUnitDecl *FromTu0 =
266 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
267 TranslationUnitDecl *FromTu1 =
268 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000269 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
270 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000271 auto *ToD0 = Import(FromD0, Lang_CXX14);
272 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000273 ASSERT_TRUE(ToD0);
274 ASSERT_TRUE(ToD1);
275 EXPECT_NE(ToD0, ToD1);
276 if (shouldBeLinked())
277 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
278 else
279 EXPECT_FALSE(ToD1->getPreviousDecl());
280 }
Balazs Kerieb79b252019-07-09 11:08:18 +0000281
282 void TypedTest_ImportAfterWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000283 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
284 TranslationUnitDecl *FromTu =
285 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000286
287 auto *ToF0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
288 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
289
Balazs Keri14d115f2019-07-15 12:16:30 +0000290 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000291
292 ASSERT_TRUE(ToF0);
293 ASSERT_TRUE(ToF1);
294
295 if (shouldBeLinked())
296 EXPECT_EQ(ToF0, ToF1);
297 else
298 EXPECT_NE(ToF0, ToF1);
299
300 // We expect no (ODR) warning during the import.
301 EXPECT_EQ(0u, ToTu->getASTContext().getDiagnostics().getNumWarnings());
302 }
303
304 void TypedTest_ImportAfterImportWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000305 TranslationUnitDecl *FromTu0 =
306 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
307 TranslationUnitDecl *FromTu1 =
308 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000309 auto *FromF0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
310 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000311 auto *ToF0 = Import(FromF0, Lang_CXX14);
312 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000313 ASSERT_TRUE(ToF0);
314 ASSERT_TRUE(ToF1);
315 if (shouldBeLinked())
316 EXPECT_EQ(ToF0, ToF1);
317 else
318 EXPECT_NE(ToF0, ToF1);
319
320 // We expect no (ODR) warning during the import.
321 EXPECT_EQ(0u, ToF0->getTranslationUnitDecl()
322 ->getASTContext()
323 .getDiagnostics()
324 .getNumWarnings());
325 }
Gabor Marton3c72fe12019-05-13 10:06:25 +0000326};
327using ImportFunctionsVisibility = ImportVisibility<GetFunPattern>;
328using ImportVariablesVisibility = ImportVisibility<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000329using ImportClassesVisibility = ImportVisibility<GetClassPattern>;
Balazs Kerieb79b252019-07-09 11:08:18 +0000330using ImportEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balázs Kérid4741c42020-02-17 14:25:16 +0100331using ImportScopedEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balazs Keric86d47b2019-09-04 14:12:18 +0000332using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000333using ImportFunctionTemplatesVisibility = ImportVisibility<GetFunTemplPattern>;
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100334using ImportVariableTemplatesVisibility = ImportVisibility<GetVarTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100335using ImportClassTemplatesVisibility = ImportVisibility<GetClassTemplPattern>;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000336
337// FunctionDecl.
338TEST_P(ImportFunctionsVisibility, ImportAfter) {
339 TypedTest_ImportAfter();
340}
341TEST_P(ImportFunctionsVisibility, ImportAfterImport) {
342 TypedTest_ImportAfterImport();
343}
344// VarDecl.
345TEST_P(ImportVariablesVisibility, ImportAfter) {
346 TypedTest_ImportAfter();
347}
348TEST_P(ImportVariablesVisibility, ImportAfterImport) {
349 TypedTest_ImportAfterImport();
350}
Balazs Keric8272192019-05-27 09:36:00 +0000351// CXXRecordDecl.
352TEST_P(ImportClassesVisibility, ImportAfter) {
353 TypedTest_ImportAfter();
354}
355TEST_P(ImportClassesVisibility, ImportAfterImport) {
356 TypedTest_ImportAfterImport();
357}
Balazs Kerieb79b252019-07-09 11:08:18 +0000358// EnumDecl.
359TEST_P(ImportEnumsVisibility, ImportAfter) {
360 TypedTest_ImportAfterWithMerge();
361}
362TEST_P(ImportEnumsVisibility, ImportAfterImport) {
363 TypedTest_ImportAfterImportWithMerge();
364}
Balázs Kérid4741c42020-02-17 14:25:16 +0100365TEST_P(ImportScopedEnumsVisibility, ImportAfter) {
366 TypedTest_ImportAfter();
367}
368TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) {
369 TypedTest_ImportAfterImport();
370}
Balazs Keric86d47b2019-09-04 14:12:18 +0000371// TypedefNameDecl.
372TEST_P(ImportTypedefNameVisibility, ImportAfter) {
373 TypedTest_ImportAfterWithMerge();
374}
375TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
376 TypedTest_ImportAfterImportWithMerge();
377}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000378// FunctionTemplateDecl.
379TEST_P(ImportFunctionTemplatesVisibility, ImportAfter) {
380 TypedTest_ImportAfter();
381}
382TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
383 TypedTest_ImportAfterImport();
384}
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100385// VarTemplateDecl.
386TEST_P(ImportVariableTemplatesVisibility, ImportAfter) {
387 TypedTest_ImportAfter();
388}
389TEST_P(ImportVariableTemplatesVisibility, ImportAfterImport) {
390 TypedTest_ImportAfterImport();
391}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100392// ClassTemplateDecl.
393TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
394TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
395 TypedTest_ImportAfterImport();
396}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000397
Balazs Kericaa42792019-09-05 07:59:45 +0000398const bool ExpectLinkedDeclChain = true;
399const bool ExpectUnlinkedDeclChain = false;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000400
401INSTANTIATE_TEST_CASE_P(
402 ParameterizedTests, ImportFunctionsVisibility,
403 ::testing::Combine(
404 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000405 ::testing::Values(
406 std::make_tuple(ExternF, ExternF, ExpectLinkedDeclChain),
407 std::make_tuple(ExternF, StaticF, ExpectUnlinkedDeclChain),
408 std::make_tuple(ExternF, AnonF, ExpectUnlinkedDeclChain),
409 std::make_tuple(StaticF, ExternF, ExpectUnlinkedDeclChain),
410 std::make_tuple(StaticF, StaticF, ExpectUnlinkedDeclChain),
411 std::make_tuple(StaticF, AnonF, ExpectUnlinkedDeclChain),
412 std::make_tuple(AnonF, ExternF, ExpectUnlinkedDeclChain),
413 std::make_tuple(AnonF, StaticF, ExpectUnlinkedDeclChain),
414 std::make_tuple(AnonF, AnonF, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000415INSTANTIATE_TEST_CASE_P(
416 ParameterizedTests, ImportVariablesVisibility,
417 ::testing::Combine(
418 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000419 ::testing::Values(
420 std::make_tuple(ExternV, ExternV, ExpectLinkedDeclChain),
421 std::make_tuple(ExternV, StaticV, ExpectUnlinkedDeclChain),
422 std::make_tuple(ExternV, AnonV, ExpectUnlinkedDeclChain),
423 std::make_tuple(StaticV, ExternV, ExpectUnlinkedDeclChain),
424 std::make_tuple(StaticV, StaticV, ExpectUnlinkedDeclChain),
425 std::make_tuple(StaticV, AnonV, ExpectUnlinkedDeclChain),
426 std::make_tuple(AnonV, ExternV, ExpectUnlinkedDeclChain),
427 std::make_tuple(AnonV, StaticV, ExpectUnlinkedDeclChain),
428 std::make_tuple(AnonV, AnonV, ExpectUnlinkedDeclChain))), );
Balazs Keric8272192019-05-27 09:36:00 +0000429INSTANTIATE_TEST_CASE_P(
430 ParameterizedTests, ImportClassesVisibility,
431 ::testing::Combine(
432 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000433 ::testing::Values(
434 std::make_tuple(ExternC, ExternC, ExpectLinkedDeclChain),
435 std::make_tuple(ExternC, AnonC, ExpectUnlinkedDeclChain),
436 std::make_tuple(AnonC, ExternC, ExpectUnlinkedDeclChain),
437 std::make_tuple(AnonC, AnonC, ExpectUnlinkedDeclChain))), );
Balazs Kerieb79b252019-07-09 11:08:18 +0000438INSTANTIATE_TEST_CASE_P(
439 ParameterizedTests, ImportEnumsVisibility,
440 ::testing::Combine(
441 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000442 ::testing::Values(
443 std::make_tuple(ExternE, ExternE, ExpectLinkedDeclChain),
444 std::make_tuple(ExternE, AnonE, ExpectUnlinkedDeclChain),
445 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
446 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
Balazs Keric86d47b2019-09-04 14:12:18 +0000447INSTANTIATE_TEST_CASE_P(
Balázs Kérid4741c42020-02-17 14:25:16 +0100448 ParameterizedTests, ImportScopedEnumsVisibility,
449 ::testing::Combine(
450 DefaultTestValuesForRunOptions,
451 ::testing::Values(
452 std::make_tuple(ExternEC, ExternEC, ExpectLinkedDeclChain),
453 std::make_tuple(ExternEC, AnonEC, ExpectUnlinkedDeclChain),
454 std::make_tuple(AnonEC, ExternEC, ExpectUnlinkedDeclChain),
455 std::make_tuple(AnonEC, AnonEC, ExpectUnlinkedDeclChain))), );
456INSTANTIATE_TEST_CASE_P(
Balazs Keric86d47b2019-09-04 14:12:18 +0000457 ParameterizedTests, ImportTypedefNameVisibility,
458 ::testing::Combine(
459 DefaultTestValuesForRunOptions,
460 ::testing::Values(
Balazs Kericaa42792019-09-05 07:59:45 +0000461 std::make_tuple(ExternTypedef, ExternTypedef,
462 ExpectLinkedDeclChain),
463 std::make_tuple(ExternTypedef, AnonTypedef,
464 ExpectUnlinkedDeclChain),
465 std::make_tuple(AnonTypedef, ExternTypedef,
466 ExpectUnlinkedDeclChain),
467 std::make_tuple(AnonTypedef, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000468
Balazs Kericaa42792019-09-05 07:59:45 +0000469 std::make_tuple(ExternUsing, ExternUsing, ExpectLinkedDeclChain),
470 std::make_tuple(ExternUsing, AnonUsing, ExpectUnlinkedDeclChain),
471 std::make_tuple(AnonUsing, ExternUsing, ExpectUnlinkedDeclChain),
472 std::make_tuple(AnonUsing, AnonUsing, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000473
Balazs Kericaa42792019-09-05 07:59:45 +0000474 std::make_tuple(ExternUsing, ExternTypedef, ExpectLinkedDeclChain),
475 std::make_tuple(ExternUsing, AnonTypedef, ExpectUnlinkedDeclChain),
476 std::make_tuple(AnonUsing, ExternTypedef, ExpectUnlinkedDeclChain),
477 std::make_tuple(AnonUsing, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000478
Balazs Kericaa42792019-09-05 07:59:45 +0000479 std::make_tuple(ExternTypedef, ExternUsing, ExpectLinkedDeclChain),
480 std::make_tuple(ExternTypedef, AnonUsing, ExpectUnlinkedDeclChain),
481 std::make_tuple(AnonTypedef, ExternUsing, ExpectUnlinkedDeclChain),
482 std::make_tuple(AnonTypedef, AnonUsing,
483 ExpectUnlinkedDeclChain))), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000484INSTANTIATE_TEST_CASE_P(
485 ParameterizedTests, ImportFunctionTemplatesVisibility,
486 ::testing::Combine(
487 DefaultTestValuesForRunOptions,
488 ::testing::Values(
489 std::make_tuple(ExternFT, ExternFT, ExpectLinkedDeclChain),
490 std::make_tuple(ExternFT, StaticFT, ExpectUnlinkedDeclChain),
491 std::make_tuple(ExternFT, AnonFT, ExpectUnlinkedDeclChain),
492 std::make_tuple(StaticFT, ExternFT, ExpectUnlinkedDeclChain),
493 std::make_tuple(StaticFT, StaticFT, ExpectUnlinkedDeclChain),
494 std::make_tuple(StaticFT, AnonFT, ExpectUnlinkedDeclChain),
495 std::make_tuple(AnonFT, ExternFT, ExpectUnlinkedDeclChain),
496 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
497 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100498INSTANTIATE_TEST_CASE_P(
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100499 ParameterizedTests, ImportVariableTemplatesVisibility,
500 ::testing::Combine(
501 DefaultTestValuesForRunOptions,
502 ::testing::Values(
503 std::make_tuple(ExternVT, ExternVT, ExpectLinkedDeclChain),
504 std::make_tuple(ExternVT, StaticVT, ExpectUnlinkedDeclChain),
505 std::make_tuple(ExternVT, AnonVT, ExpectUnlinkedDeclChain),
506 std::make_tuple(StaticVT, ExternVT, ExpectUnlinkedDeclChain),
507 std::make_tuple(StaticVT, StaticVT, ExpectUnlinkedDeclChain),
508 std::make_tuple(StaticVT, AnonVT, ExpectUnlinkedDeclChain),
509 std::make_tuple(AnonVT, ExternVT, ExpectUnlinkedDeclChain),
510 std::make_tuple(AnonVT, StaticVT, ExpectUnlinkedDeclChain),
511 std::make_tuple(AnonVT, AnonVT, ExpectUnlinkedDeclChain))), );
512INSTANTIATE_TEST_CASE_P(
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100513 ParameterizedTests, ImportClassTemplatesVisibility,
514 ::testing::Combine(
515 DefaultTestValuesForRunOptions,
516 ::testing::Values(std::make_tuple(ExternCT, ExternCT, ExpectLinkedDeclChain),
517 std::make_tuple(ExternCT, AnonCT, ExpectUnlinkedDeclChain),
518 std::make_tuple(AnonCT, ExternCT, ExpectUnlinkedDeclChain),
519 std::make_tuple(AnonCT, AnonCT, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000520} // end namespace ast_matchers
521} // end namespace clang