blob: 00a307b8940b1255598c895574d354a1dab9201b [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.
99using ImportVisibilityChainParams =
100 ::testing::WithParamInterface<std::tuple<ArgVector, const char *>>;
101// 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;
112 ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
113 std::string getCode() const { return std::get<1>(GetParam()); }
114 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
115
116 // Type-parameterized test.
117 void TypedTest_ImportChain() {
118 std::string Code = getCode() + getCode();
119 auto Pattern = getPattern();
120
Balazs Keri14d115f2019-07-15 12:16:30 +0000121 TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX14, "input0.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000122
123 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu, Pattern);
124 auto *FromD1 = LastDeclMatcher<DeclTy>().match(FromTu, Pattern);
125
Balazs Keri14d115f2019-07-15 12:16:30 +0000126 auto *ToD0 = Import(FromD0, Lang_CXX14);
127 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000128
129 EXPECT_TRUE(ToD0);
130 ASSERT_TRUE(ToD1);
131 EXPECT_NE(ToD0, ToD1);
132 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
133 }
134};
135
136// Manual instantiation of the fixture with each type.
137using ImportFunctionsVisibilityChain = ImportVisibilityChain<GetFunPattern>;
138using ImportVariablesVisibilityChain = ImportVisibilityChain<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000139using ImportClassesVisibilityChain = ImportVisibilityChain<GetClassPattern>;
Balázs Kérid4741c42020-02-17 14:25:16 +0100140using ImportScopedEnumsVisibilityChain = ImportVisibilityChain<GetEnumPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000141using ImportFunctionTemplatesVisibilityChain =
142 ImportVisibilityChain<GetFunTemplPattern>;
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100143using ImportVariableTemplatesVisibilityChain =
144 ImportVisibilityChain<GetVarTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100145using ImportClassTemplatesVisibilityChain =
146 ImportVisibilityChain<GetClassTemplPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000147
Balazs Keric8272192019-05-27 09:36:00 +0000148// Value-parameterized test for functions.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000149TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
150 TypedTest_ImportChain();
151}
Balazs Keric8272192019-05-27 09:36:00 +0000152// Value-parameterized test for variables.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000153TEST_P(ImportVariablesVisibilityChain, ImportChain) {
154 TypedTest_ImportChain();
155}
Balazs Keric8272192019-05-27 09:36:00 +0000156// Value-parameterized test for classes.
157TEST_P(ImportClassesVisibilityChain, ImportChain) {
158 TypedTest_ImportChain();
159}
Balázs Kérid4741c42020-02-17 14:25:16 +0100160// Value-parameterized test for scoped enums.
161TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
162 TypedTest_ImportChain();
163}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000164// Value-parameterized test for function templates.
165TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
166 TypedTest_ImportChain();
167}
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100168// Value-parameterized test for variable templates.
169TEST_P(ImportVariableTemplatesVisibilityChain, ImportChain) {
170 TypedTest_ImportChain();
171}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100172// Value-parameterized test for class templates.
173TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
174 TypedTest_ImportChain();
175}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000176
177// Automatic instantiation of the value-parameterized tests.
178INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
179 ::testing::Combine(
180 DefaultTestValuesForRunOptions,
181 ::testing::Values(ExternF, StaticF, AnonF)), );
182INSTANTIATE_TEST_CASE_P(
183 ParameterizedTests, ImportVariablesVisibilityChain,
184 ::testing::Combine(
185 DefaultTestValuesForRunOptions,
186 // There is no point to instantiate with StaticV, because in C++ we can
187 // forward declare a variable only with the 'extern' keyword.
188 // Consequently, each fwd declared variable has external linkage. This
189 // is different in the C language where any declaration without an
190 // initializer is a tentative definition, subsequent definitions may be
191 // provided but they must have the same linkage. See also the test
192 // ImportVariableChainInC which test for this special C Lang case.
193 ::testing::Values(ExternV, AnonV)), );
Balazs Keric8272192019-05-27 09:36:00 +0000194INSTANTIATE_TEST_CASE_P(
195 ParameterizedTests, ImportClassesVisibilityChain,
196 ::testing::Combine(
197 DefaultTestValuesForRunOptions,
198 ::testing::Values(ExternC, AnonC)), );
Balázs Kérid4741c42020-02-17 14:25:16 +0100199INSTANTIATE_TEST_CASE_P(
200 ParameterizedTests, ImportScopedEnumsVisibilityChain,
201 ::testing::Combine(
202 DefaultTestValuesForRunOptions,
203 ::testing::Values(ExternEC, AnonEC)), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000204INSTANTIATE_TEST_CASE_P(ParameterizedTests,
205 ImportFunctionTemplatesVisibilityChain,
206 ::testing::Combine(DefaultTestValuesForRunOptions,
207 ::testing::Values(ExternFT, StaticFT,
208 AnonFT)), );
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100209INSTANTIATE_TEST_CASE_P(ParameterizedTests,
210 ImportVariableTemplatesVisibilityChain,
211 ::testing::Combine(DefaultTestValuesForRunOptions,
212 ::testing::Values(ExternVT,
213 AnonVT)), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100214INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
215 ::testing::Combine(DefaultTestValuesForRunOptions,
216 ::testing::Values(ExternCT,
217 AnonCT)), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000218
219// First value in tuple: Compile options.
220// Second value in tuple: Tuple with informations for the test.
221// Code for first import (or initial code), code to import, whether the `f`
222// functions are expected to be linked in a declaration chain.
223// One value of this tuple is combined with every value of compile options.
224// The test can have a single tuple as parameter only.
225using ImportVisibilityParams = ::testing::WithParamInterface<
226 std::tuple<ArgVector, std::tuple<const char *, const char *, bool>>>;
227
228template <typename PatternFactory>
229class ImportVisibility
230 : public ASTImporterTestBase,
231 public ImportVisibilityParams {
232protected:
233 using DeclTy = typename PatternFactory::DeclTy;
234 ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
235 std::string getCode0() const { return std::get<0>(std::get<1>(GetParam())); }
236 std::string getCode1() const { return std::get<1>(std::get<1>(GetParam())); }
237 bool shouldBeLinked() const { return std::get<2>(std::get<1>(GetParam())); }
238 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
239
240 void TypedTest_ImportAfter() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000241 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
242 TranslationUnitDecl *FromTu =
243 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000244
245 auto *ToD0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
246 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
247
Balazs Keri14d115f2019-07-15 12:16:30 +0000248 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000249
250 ASSERT_TRUE(ToD0);
251 ASSERT_TRUE(ToD1);
252 EXPECT_NE(ToD0, ToD1);
253
254 if (shouldBeLinked())
255 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
256 else
257 EXPECT_FALSE(ToD1->getPreviousDecl());
258 }
259
260 void TypedTest_ImportAfterImport() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000261 TranslationUnitDecl *FromTu0 =
262 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
263 TranslationUnitDecl *FromTu1 =
264 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000265 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
266 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000267 auto *ToD0 = Import(FromD0, Lang_CXX14);
268 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000269 ASSERT_TRUE(ToD0);
270 ASSERT_TRUE(ToD1);
271 EXPECT_NE(ToD0, ToD1);
272 if (shouldBeLinked())
273 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
274 else
275 EXPECT_FALSE(ToD1->getPreviousDecl());
276 }
Balazs Kerieb79b252019-07-09 11:08:18 +0000277
278 void TypedTest_ImportAfterWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000279 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
280 TranslationUnitDecl *FromTu =
281 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000282
283 auto *ToF0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
284 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
285
Balazs Keri14d115f2019-07-15 12:16:30 +0000286 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000287
288 ASSERT_TRUE(ToF0);
289 ASSERT_TRUE(ToF1);
290
291 if (shouldBeLinked())
292 EXPECT_EQ(ToF0, ToF1);
293 else
294 EXPECT_NE(ToF0, ToF1);
295
296 // We expect no (ODR) warning during the import.
297 EXPECT_EQ(0u, ToTu->getASTContext().getDiagnostics().getNumWarnings());
298 }
299
300 void TypedTest_ImportAfterImportWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000301 TranslationUnitDecl *FromTu0 =
302 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
303 TranslationUnitDecl *FromTu1 =
304 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000305 auto *FromF0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
306 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000307 auto *ToF0 = Import(FromF0, Lang_CXX14);
308 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000309 ASSERT_TRUE(ToF0);
310 ASSERT_TRUE(ToF1);
311 if (shouldBeLinked())
312 EXPECT_EQ(ToF0, ToF1);
313 else
314 EXPECT_NE(ToF0, ToF1);
315
316 // We expect no (ODR) warning during the import.
317 EXPECT_EQ(0u, ToF0->getTranslationUnitDecl()
318 ->getASTContext()
319 .getDiagnostics()
320 .getNumWarnings());
321 }
Gabor Marton3c72fe12019-05-13 10:06:25 +0000322};
323using ImportFunctionsVisibility = ImportVisibility<GetFunPattern>;
324using ImportVariablesVisibility = ImportVisibility<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000325using ImportClassesVisibility = ImportVisibility<GetClassPattern>;
Balazs Kerieb79b252019-07-09 11:08:18 +0000326using ImportEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balázs Kérid4741c42020-02-17 14:25:16 +0100327using ImportScopedEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balazs Keric86d47b2019-09-04 14:12:18 +0000328using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000329using ImportFunctionTemplatesVisibility = ImportVisibility<GetFunTemplPattern>;
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100330using ImportVariableTemplatesVisibility = ImportVisibility<GetVarTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100331using ImportClassTemplatesVisibility = ImportVisibility<GetClassTemplPattern>;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000332
333// FunctionDecl.
334TEST_P(ImportFunctionsVisibility, ImportAfter) {
335 TypedTest_ImportAfter();
336}
337TEST_P(ImportFunctionsVisibility, ImportAfterImport) {
338 TypedTest_ImportAfterImport();
339}
340// VarDecl.
341TEST_P(ImportVariablesVisibility, ImportAfter) {
342 TypedTest_ImportAfter();
343}
344TEST_P(ImportVariablesVisibility, ImportAfterImport) {
345 TypedTest_ImportAfterImport();
346}
Balazs Keric8272192019-05-27 09:36:00 +0000347// CXXRecordDecl.
348TEST_P(ImportClassesVisibility, ImportAfter) {
349 TypedTest_ImportAfter();
350}
351TEST_P(ImportClassesVisibility, ImportAfterImport) {
352 TypedTest_ImportAfterImport();
353}
Balazs Kerieb79b252019-07-09 11:08:18 +0000354// EnumDecl.
355TEST_P(ImportEnumsVisibility, ImportAfter) {
356 TypedTest_ImportAfterWithMerge();
357}
358TEST_P(ImportEnumsVisibility, ImportAfterImport) {
359 TypedTest_ImportAfterImportWithMerge();
360}
Balázs Kérid4741c42020-02-17 14:25:16 +0100361TEST_P(ImportScopedEnumsVisibility, ImportAfter) {
362 TypedTest_ImportAfter();
363}
364TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) {
365 TypedTest_ImportAfterImport();
366}
Balazs Keric86d47b2019-09-04 14:12:18 +0000367// TypedefNameDecl.
368TEST_P(ImportTypedefNameVisibility, ImportAfter) {
369 TypedTest_ImportAfterWithMerge();
370}
371TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
372 TypedTest_ImportAfterImportWithMerge();
373}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000374// FunctionTemplateDecl.
375TEST_P(ImportFunctionTemplatesVisibility, ImportAfter) {
376 TypedTest_ImportAfter();
377}
378TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
379 TypedTest_ImportAfterImport();
380}
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100381// VarTemplateDecl.
382TEST_P(ImportVariableTemplatesVisibility, ImportAfter) {
383 TypedTest_ImportAfter();
384}
385TEST_P(ImportVariableTemplatesVisibility, ImportAfterImport) {
386 TypedTest_ImportAfterImport();
387}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100388// ClassTemplateDecl.
389TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
390TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
391 TypedTest_ImportAfterImport();
392}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000393
Balazs Kericaa42792019-09-05 07:59:45 +0000394const bool ExpectLinkedDeclChain = true;
395const bool ExpectUnlinkedDeclChain = false;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000396
397INSTANTIATE_TEST_CASE_P(
398 ParameterizedTests, ImportFunctionsVisibility,
399 ::testing::Combine(
400 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000401 ::testing::Values(
402 std::make_tuple(ExternF, ExternF, ExpectLinkedDeclChain),
403 std::make_tuple(ExternF, StaticF, ExpectUnlinkedDeclChain),
404 std::make_tuple(ExternF, AnonF, ExpectUnlinkedDeclChain),
405 std::make_tuple(StaticF, ExternF, ExpectUnlinkedDeclChain),
406 std::make_tuple(StaticF, StaticF, ExpectUnlinkedDeclChain),
407 std::make_tuple(StaticF, AnonF, ExpectUnlinkedDeclChain),
408 std::make_tuple(AnonF, ExternF, ExpectUnlinkedDeclChain),
409 std::make_tuple(AnonF, StaticF, ExpectUnlinkedDeclChain),
410 std::make_tuple(AnonF, AnonF, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000411INSTANTIATE_TEST_CASE_P(
412 ParameterizedTests, ImportVariablesVisibility,
413 ::testing::Combine(
414 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000415 ::testing::Values(
416 std::make_tuple(ExternV, ExternV, ExpectLinkedDeclChain),
417 std::make_tuple(ExternV, StaticV, ExpectUnlinkedDeclChain),
418 std::make_tuple(ExternV, AnonV, ExpectUnlinkedDeclChain),
419 std::make_tuple(StaticV, ExternV, ExpectUnlinkedDeclChain),
420 std::make_tuple(StaticV, StaticV, ExpectUnlinkedDeclChain),
421 std::make_tuple(StaticV, AnonV, ExpectUnlinkedDeclChain),
422 std::make_tuple(AnonV, ExternV, ExpectUnlinkedDeclChain),
423 std::make_tuple(AnonV, StaticV, ExpectUnlinkedDeclChain),
424 std::make_tuple(AnonV, AnonV, ExpectUnlinkedDeclChain))), );
Balazs Keric8272192019-05-27 09:36:00 +0000425INSTANTIATE_TEST_CASE_P(
426 ParameterizedTests, ImportClassesVisibility,
427 ::testing::Combine(
428 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000429 ::testing::Values(
430 std::make_tuple(ExternC, ExternC, ExpectLinkedDeclChain),
431 std::make_tuple(ExternC, AnonC, ExpectUnlinkedDeclChain),
432 std::make_tuple(AnonC, ExternC, ExpectUnlinkedDeclChain),
433 std::make_tuple(AnonC, AnonC, ExpectUnlinkedDeclChain))), );
Balazs Kerieb79b252019-07-09 11:08:18 +0000434INSTANTIATE_TEST_CASE_P(
435 ParameterizedTests, ImportEnumsVisibility,
436 ::testing::Combine(
437 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000438 ::testing::Values(
439 std::make_tuple(ExternE, ExternE, ExpectLinkedDeclChain),
440 std::make_tuple(ExternE, AnonE, ExpectUnlinkedDeclChain),
441 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
442 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
Balazs Keric86d47b2019-09-04 14:12:18 +0000443INSTANTIATE_TEST_CASE_P(
Balázs Kérid4741c42020-02-17 14:25:16 +0100444 ParameterizedTests, ImportScopedEnumsVisibility,
445 ::testing::Combine(
446 DefaultTestValuesForRunOptions,
447 ::testing::Values(
448 std::make_tuple(ExternEC, ExternEC, ExpectLinkedDeclChain),
449 std::make_tuple(ExternEC, AnonEC, ExpectUnlinkedDeclChain),
450 std::make_tuple(AnonEC, ExternEC, ExpectUnlinkedDeclChain),
451 std::make_tuple(AnonEC, AnonEC, ExpectUnlinkedDeclChain))), );
452INSTANTIATE_TEST_CASE_P(
Balazs Keric86d47b2019-09-04 14:12:18 +0000453 ParameterizedTests, ImportTypedefNameVisibility,
454 ::testing::Combine(
455 DefaultTestValuesForRunOptions,
456 ::testing::Values(
Balazs Kericaa42792019-09-05 07:59:45 +0000457 std::make_tuple(ExternTypedef, ExternTypedef,
458 ExpectLinkedDeclChain),
459 std::make_tuple(ExternTypedef, AnonTypedef,
460 ExpectUnlinkedDeclChain),
461 std::make_tuple(AnonTypedef, ExternTypedef,
462 ExpectUnlinkedDeclChain),
463 std::make_tuple(AnonTypedef, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000464
Balazs Kericaa42792019-09-05 07:59:45 +0000465 std::make_tuple(ExternUsing, ExternUsing, ExpectLinkedDeclChain),
466 std::make_tuple(ExternUsing, AnonUsing, ExpectUnlinkedDeclChain),
467 std::make_tuple(AnonUsing, ExternUsing, ExpectUnlinkedDeclChain),
468 std::make_tuple(AnonUsing, AnonUsing, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000469
Balazs Kericaa42792019-09-05 07:59:45 +0000470 std::make_tuple(ExternUsing, ExternTypedef, ExpectLinkedDeclChain),
471 std::make_tuple(ExternUsing, AnonTypedef, ExpectUnlinkedDeclChain),
472 std::make_tuple(AnonUsing, ExternTypedef, ExpectUnlinkedDeclChain),
473 std::make_tuple(AnonUsing, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000474
Balazs Kericaa42792019-09-05 07:59:45 +0000475 std::make_tuple(ExternTypedef, ExternUsing, ExpectLinkedDeclChain),
476 std::make_tuple(ExternTypedef, AnonUsing, ExpectUnlinkedDeclChain),
477 std::make_tuple(AnonTypedef, ExternUsing, ExpectUnlinkedDeclChain),
478 std::make_tuple(AnonTypedef, AnonUsing,
479 ExpectUnlinkedDeclChain))), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000480INSTANTIATE_TEST_CASE_P(
481 ParameterizedTests, ImportFunctionTemplatesVisibility,
482 ::testing::Combine(
483 DefaultTestValuesForRunOptions,
484 ::testing::Values(
485 std::make_tuple(ExternFT, ExternFT, ExpectLinkedDeclChain),
486 std::make_tuple(ExternFT, StaticFT, ExpectUnlinkedDeclChain),
487 std::make_tuple(ExternFT, AnonFT, ExpectUnlinkedDeclChain),
488 std::make_tuple(StaticFT, ExternFT, ExpectUnlinkedDeclChain),
489 std::make_tuple(StaticFT, StaticFT, ExpectUnlinkedDeclChain),
490 std::make_tuple(StaticFT, AnonFT, ExpectUnlinkedDeclChain),
491 std::make_tuple(AnonFT, ExternFT, ExpectUnlinkedDeclChain),
492 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
493 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100494INSTANTIATE_TEST_CASE_P(
Balázs Kéri8d67bcf2020-03-09 11:01:48 +0100495 ParameterizedTests, ImportVariableTemplatesVisibility,
496 ::testing::Combine(
497 DefaultTestValuesForRunOptions,
498 ::testing::Values(
499 std::make_tuple(ExternVT, ExternVT, ExpectLinkedDeclChain),
500 std::make_tuple(ExternVT, StaticVT, ExpectUnlinkedDeclChain),
501 std::make_tuple(ExternVT, AnonVT, ExpectUnlinkedDeclChain),
502 std::make_tuple(StaticVT, ExternVT, ExpectUnlinkedDeclChain),
503 std::make_tuple(StaticVT, StaticVT, ExpectUnlinkedDeclChain),
504 std::make_tuple(StaticVT, AnonVT, ExpectUnlinkedDeclChain),
505 std::make_tuple(AnonVT, ExternVT, ExpectUnlinkedDeclChain),
506 std::make_tuple(AnonVT, StaticVT, ExpectUnlinkedDeclChain),
507 std::make_tuple(AnonVT, AnonVT, ExpectUnlinkedDeclChain))), );
508INSTANTIATE_TEST_CASE_P(
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100509 ParameterizedTests, ImportClassTemplatesVisibility,
510 ::testing::Combine(
511 DefaultTestValuesForRunOptions,
512 ::testing::Values(std::make_tuple(ExternCT, ExternCT, ExpectLinkedDeclChain),
513 std::make_tuple(ExternCT, AnonCT, ExpectUnlinkedDeclChain),
514 std::make_tuple(AnonCT, ExternCT, ExpectUnlinkedDeclChain),
515 std::make_tuple(AnonCT, AnonCT, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000516} // end namespace ast_matchers
517} // end namespace clang