blob: 14a6706cc7617f5f7f57bf6ade5741d2e9cb399b [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éric2f6efc2019-11-15 15:05:20 +010052struct GetClassTemplPattern {
53 using DeclTy = ClassTemplateDecl;
54 BindableMatcher<Decl> operator()() { return classTemplateDecl(hasName("X")); }
55};
Gabor Marton3c72fe12019-05-13 10:06:25 +000056
57// Values for the value-parameterized test fixtures.
58// FunctionDecl:
59const auto *ExternF = "void f();";
60const auto *StaticF = "static void f();";
61const auto *AnonF = "namespace { void f(); }";
62// VarDecl:
63const auto *ExternV = "extern int v;";
64const auto *StaticV = "static int v;";
65const auto *AnonV = "namespace { extern int v; }";
Balazs Keric8272192019-05-27 09:36:00 +000066// CXXRecordDecl:
67const auto *ExternC = "class X;";
68const auto *AnonC = "namespace { class X; }";
Balazs Kerieb79b252019-07-09 11:08:18 +000069// EnumDecl:
70const auto *ExternE = "enum E {};";
71const auto *AnonE = "namespace { enum E {}; }";
Balázs Kérid4741c42020-02-17 14:25:16 +010072const auto *ExternEC = "enum class E;";
73const auto *AnonEC = "namespace { enum class E; }";
Balazs Keric86d47b2019-09-04 14:12:18 +000074// TypedefNameDecl:
75const auto *ExternTypedef = "typedef int T;";
76const auto *AnonTypedef = "namespace { typedef int T; }";
77const auto *ExternUsing = "using T = int;";
78const auto *AnonUsing = "namespace { using T = int; }";
Balazs Kerif8a89c82019-09-13 08:03:49 +000079// FunctionTemplateDecl:
80const auto *ExternFT = "template <class> void f();";
81const auto *StaticFT = "template <class> static void f();";
82const auto *AnonFT = "namespace { template <class> void f(); }";
Balázs Kéric2f6efc2019-11-15 15:05:20 +010083// ClassTemplateDecl:
84const auto *ExternCT = "template <class> class X;";
85const auto *AnonCT = "namespace { template <class> class X; }";
Gabor Marton3c72fe12019-05-13 10:06:25 +000086
87// First value in tuple: Compile options.
88// Second value in tuple: Source code to be used in the test.
89using ImportVisibilityChainParams =
90 ::testing::WithParamInterface<std::tuple<ArgVector, const char *>>;
91// Fixture to test the redecl chain of Decls with the same visibility. Gtest
92// makes it possible to have either value-parameterized or type-parameterized
93// fixtures. However, we cannot have both value- and type-parameterized test
94// fixtures. This is a value-parameterized test fixture in the gtest sense. We
95// intend to mimic gtest's type-parameters via the PatternFactory template
96// parameter. We manually instantiate the different tests with the each types.
97template <typename PatternFactory>
98class ImportVisibilityChain
99 : public ASTImporterTestBase, public ImportVisibilityChainParams {
100protected:
101 using DeclTy = typename PatternFactory::DeclTy;
102 ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
103 std::string getCode() const { return std::get<1>(GetParam()); }
104 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
105
106 // Type-parameterized test.
107 void TypedTest_ImportChain() {
108 std::string Code = getCode() + getCode();
109 auto Pattern = getPattern();
110
Balazs Keri14d115f2019-07-15 12:16:30 +0000111 TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX14, "input0.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000112
113 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu, Pattern);
114 auto *FromD1 = LastDeclMatcher<DeclTy>().match(FromTu, Pattern);
115
Balazs Keri14d115f2019-07-15 12:16:30 +0000116 auto *ToD0 = Import(FromD0, Lang_CXX14);
117 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000118
119 EXPECT_TRUE(ToD0);
120 ASSERT_TRUE(ToD1);
121 EXPECT_NE(ToD0, ToD1);
122 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
123 }
124};
125
126// Manual instantiation of the fixture with each type.
127using ImportFunctionsVisibilityChain = ImportVisibilityChain<GetFunPattern>;
128using ImportVariablesVisibilityChain = ImportVisibilityChain<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000129using ImportClassesVisibilityChain = ImportVisibilityChain<GetClassPattern>;
Balázs Kérid4741c42020-02-17 14:25:16 +0100130using ImportScopedEnumsVisibilityChain = ImportVisibilityChain<GetEnumPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000131using ImportFunctionTemplatesVisibilityChain =
132 ImportVisibilityChain<GetFunTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100133using ImportClassTemplatesVisibilityChain =
134 ImportVisibilityChain<GetClassTemplPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000135
Balazs Keric8272192019-05-27 09:36:00 +0000136// Value-parameterized test for functions.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000137TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
138 TypedTest_ImportChain();
139}
Balazs Keric8272192019-05-27 09:36:00 +0000140// Value-parameterized test for variables.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000141TEST_P(ImportVariablesVisibilityChain, ImportChain) {
142 TypedTest_ImportChain();
143}
Balazs Keric8272192019-05-27 09:36:00 +0000144// Value-parameterized test for classes.
145TEST_P(ImportClassesVisibilityChain, ImportChain) {
146 TypedTest_ImportChain();
147}
Balázs Kérid4741c42020-02-17 14:25:16 +0100148// Value-parameterized test for scoped enums.
149TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
150 TypedTest_ImportChain();
151}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000152// Value-parameterized test for function templates.
153TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
154 TypedTest_ImportChain();
155}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100156// Value-parameterized test for class templates.
157TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
158 TypedTest_ImportChain();
159}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000160
161// Automatic instantiation of the value-parameterized tests.
162INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
163 ::testing::Combine(
164 DefaultTestValuesForRunOptions,
165 ::testing::Values(ExternF, StaticF, AnonF)), );
166INSTANTIATE_TEST_CASE_P(
167 ParameterizedTests, ImportVariablesVisibilityChain,
168 ::testing::Combine(
169 DefaultTestValuesForRunOptions,
170 // There is no point to instantiate with StaticV, because in C++ we can
171 // forward declare a variable only with the 'extern' keyword.
172 // Consequently, each fwd declared variable has external linkage. This
173 // is different in the C language where any declaration without an
174 // initializer is a tentative definition, subsequent definitions may be
175 // provided but they must have the same linkage. See also the test
176 // ImportVariableChainInC which test for this special C Lang case.
177 ::testing::Values(ExternV, AnonV)), );
Balazs Keric8272192019-05-27 09:36:00 +0000178INSTANTIATE_TEST_CASE_P(
179 ParameterizedTests, ImportClassesVisibilityChain,
180 ::testing::Combine(
181 DefaultTestValuesForRunOptions,
182 ::testing::Values(ExternC, AnonC)), );
Balázs Kérid4741c42020-02-17 14:25:16 +0100183INSTANTIATE_TEST_CASE_P(
184 ParameterizedTests, ImportScopedEnumsVisibilityChain,
185 ::testing::Combine(
186 DefaultTestValuesForRunOptions,
187 ::testing::Values(ExternEC, AnonEC)), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000188INSTANTIATE_TEST_CASE_P(ParameterizedTests,
189 ImportFunctionTemplatesVisibilityChain,
190 ::testing::Combine(DefaultTestValuesForRunOptions,
191 ::testing::Values(ExternFT, StaticFT,
192 AnonFT)), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100193INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
194 ::testing::Combine(DefaultTestValuesForRunOptions,
195 ::testing::Values(ExternCT,
196 AnonCT)), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000197
198// First value in tuple: Compile options.
199// Second value in tuple: Tuple with informations for the test.
200// Code for first import (or initial code), code to import, whether the `f`
201// functions are expected to be linked in a declaration chain.
202// One value of this tuple is combined with every value of compile options.
203// The test can have a single tuple as parameter only.
204using ImportVisibilityParams = ::testing::WithParamInterface<
205 std::tuple<ArgVector, std::tuple<const char *, const char *, bool>>>;
206
207template <typename PatternFactory>
208class ImportVisibility
209 : public ASTImporterTestBase,
210 public ImportVisibilityParams {
211protected:
212 using DeclTy = typename PatternFactory::DeclTy;
213 ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
214 std::string getCode0() const { return std::get<0>(std::get<1>(GetParam())); }
215 std::string getCode1() const { return std::get<1>(std::get<1>(GetParam())); }
216 bool shouldBeLinked() const { return std::get<2>(std::get<1>(GetParam())); }
217 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
218
219 void TypedTest_ImportAfter() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000220 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
221 TranslationUnitDecl *FromTu =
222 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000223
224 auto *ToD0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
225 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
226
Balazs Keri14d115f2019-07-15 12:16:30 +0000227 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000228
229 ASSERT_TRUE(ToD0);
230 ASSERT_TRUE(ToD1);
231 EXPECT_NE(ToD0, ToD1);
232
233 if (shouldBeLinked())
234 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
235 else
236 EXPECT_FALSE(ToD1->getPreviousDecl());
237 }
238
239 void TypedTest_ImportAfterImport() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000240 TranslationUnitDecl *FromTu0 =
241 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
242 TranslationUnitDecl *FromTu1 =
243 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000244 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
245 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000246 auto *ToD0 = Import(FromD0, Lang_CXX14);
247 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000248 ASSERT_TRUE(ToD0);
249 ASSERT_TRUE(ToD1);
250 EXPECT_NE(ToD0, ToD1);
251 if (shouldBeLinked())
252 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
253 else
254 EXPECT_FALSE(ToD1->getPreviousDecl());
255 }
Balazs Kerieb79b252019-07-09 11:08:18 +0000256
257 void TypedTest_ImportAfterWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000258 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
259 TranslationUnitDecl *FromTu =
260 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000261
262 auto *ToF0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
263 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
264
Balazs Keri14d115f2019-07-15 12:16:30 +0000265 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000266
267 ASSERT_TRUE(ToF0);
268 ASSERT_TRUE(ToF1);
269
270 if (shouldBeLinked())
271 EXPECT_EQ(ToF0, ToF1);
272 else
273 EXPECT_NE(ToF0, ToF1);
274
275 // We expect no (ODR) warning during the import.
276 EXPECT_EQ(0u, ToTu->getASTContext().getDiagnostics().getNumWarnings());
277 }
278
279 void TypedTest_ImportAfterImportWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000280 TranslationUnitDecl *FromTu0 =
281 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
282 TranslationUnitDecl *FromTu1 =
283 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000284 auto *FromF0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
285 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000286 auto *ToF0 = Import(FromF0, Lang_CXX14);
287 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000288 ASSERT_TRUE(ToF0);
289 ASSERT_TRUE(ToF1);
290 if (shouldBeLinked())
291 EXPECT_EQ(ToF0, ToF1);
292 else
293 EXPECT_NE(ToF0, ToF1);
294
295 // We expect no (ODR) warning during the import.
296 EXPECT_EQ(0u, ToF0->getTranslationUnitDecl()
297 ->getASTContext()
298 .getDiagnostics()
299 .getNumWarnings());
300 }
Gabor Marton3c72fe12019-05-13 10:06:25 +0000301};
302using ImportFunctionsVisibility = ImportVisibility<GetFunPattern>;
303using ImportVariablesVisibility = ImportVisibility<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000304using ImportClassesVisibility = ImportVisibility<GetClassPattern>;
Balazs Kerieb79b252019-07-09 11:08:18 +0000305using ImportEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balázs Kérid4741c42020-02-17 14:25:16 +0100306using ImportScopedEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balazs Keric86d47b2019-09-04 14:12:18 +0000307using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000308using ImportFunctionTemplatesVisibility = ImportVisibility<GetFunTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100309using ImportClassTemplatesVisibility = ImportVisibility<GetClassTemplPattern>;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000310
311// FunctionDecl.
312TEST_P(ImportFunctionsVisibility, ImportAfter) {
313 TypedTest_ImportAfter();
314}
315TEST_P(ImportFunctionsVisibility, ImportAfterImport) {
316 TypedTest_ImportAfterImport();
317}
318// VarDecl.
319TEST_P(ImportVariablesVisibility, ImportAfter) {
320 TypedTest_ImportAfter();
321}
322TEST_P(ImportVariablesVisibility, ImportAfterImport) {
323 TypedTest_ImportAfterImport();
324}
Balazs Keric8272192019-05-27 09:36:00 +0000325// CXXRecordDecl.
326TEST_P(ImportClassesVisibility, ImportAfter) {
327 TypedTest_ImportAfter();
328}
329TEST_P(ImportClassesVisibility, ImportAfterImport) {
330 TypedTest_ImportAfterImport();
331}
Balazs Kerieb79b252019-07-09 11:08:18 +0000332// EnumDecl.
333TEST_P(ImportEnumsVisibility, ImportAfter) {
334 TypedTest_ImportAfterWithMerge();
335}
336TEST_P(ImportEnumsVisibility, ImportAfterImport) {
337 TypedTest_ImportAfterImportWithMerge();
338}
Balázs Kérid4741c42020-02-17 14:25:16 +0100339TEST_P(ImportScopedEnumsVisibility, ImportAfter) {
340 TypedTest_ImportAfter();
341}
342TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) {
343 TypedTest_ImportAfterImport();
344}
Balazs Keric86d47b2019-09-04 14:12:18 +0000345// TypedefNameDecl.
346TEST_P(ImportTypedefNameVisibility, ImportAfter) {
347 TypedTest_ImportAfterWithMerge();
348}
349TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
350 TypedTest_ImportAfterImportWithMerge();
351}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000352// FunctionTemplateDecl.
353TEST_P(ImportFunctionTemplatesVisibility, ImportAfter) {
354 TypedTest_ImportAfter();
355}
356TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
357 TypedTest_ImportAfterImport();
358}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100359// ClassTemplateDecl.
360TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
361TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
362 TypedTest_ImportAfterImport();
363}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000364
Balazs Kericaa42792019-09-05 07:59:45 +0000365const bool ExpectLinkedDeclChain = true;
366const bool ExpectUnlinkedDeclChain = false;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000367
368INSTANTIATE_TEST_CASE_P(
369 ParameterizedTests, ImportFunctionsVisibility,
370 ::testing::Combine(
371 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000372 ::testing::Values(
373 std::make_tuple(ExternF, ExternF, ExpectLinkedDeclChain),
374 std::make_tuple(ExternF, StaticF, ExpectUnlinkedDeclChain),
375 std::make_tuple(ExternF, AnonF, ExpectUnlinkedDeclChain),
376 std::make_tuple(StaticF, ExternF, ExpectUnlinkedDeclChain),
377 std::make_tuple(StaticF, StaticF, ExpectUnlinkedDeclChain),
378 std::make_tuple(StaticF, AnonF, ExpectUnlinkedDeclChain),
379 std::make_tuple(AnonF, ExternF, ExpectUnlinkedDeclChain),
380 std::make_tuple(AnonF, StaticF, ExpectUnlinkedDeclChain),
381 std::make_tuple(AnonF, AnonF, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000382INSTANTIATE_TEST_CASE_P(
383 ParameterizedTests, ImportVariablesVisibility,
384 ::testing::Combine(
385 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000386 ::testing::Values(
387 std::make_tuple(ExternV, ExternV, ExpectLinkedDeclChain),
388 std::make_tuple(ExternV, StaticV, ExpectUnlinkedDeclChain),
389 std::make_tuple(ExternV, AnonV, ExpectUnlinkedDeclChain),
390 std::make_tuple(StaticV, ExternV, ExpectUnlinkedDeclChain),
391 std::make_tuple(StaticV, StaticV, ExpectUnlinkedDeclChain),
392 std::make_tuple(StaticV, AnonV, ExpectUnlinkedDeclChain),
393 std::make_tuple(AnonV, ExternV, ExpectUnlinkedDeclChain),
394 std::make_tuple(AnonV, StaticV, ExpectUnlinkedDeclChain),
395 std::make_tuple(AnonV, AnonV, ExpectUnlinkedDeclChain))), );
Balazs Keric8272192019-05-27 09:36:00 +0000396INSTANTIATE_TEST_CASE_P(
397 ParameterizedTests, ImportClassesVisibility,
398 ::testing::Combine(
399 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000400 ::testing::Values(
401 std::make_tuple(ExternC, ExternC, ExpectLinkedDeclChain),
402 std::make_tuple(ExternC, AnonC, ExpectUnlinkedDeclChain),
403 std::make_tuple(AnonC, ExternC, ExpectUnlinkedDeclChain),
404 std::make_tuple(AnonC, AnonC, ExpectUnlinkedDeclChain))), );
Balazs Kerieb79b252019-07-09 11:08:18 +0000405INSTANTIATE_TEST_CASE_P(
406 ParameterizedTests, ImportEnumsVisibility,
407 ::testing::Combine(
408 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000409 ::testing::Values(
410 std::make_tuple(ExternE, ExternE, ExpectLinkedDeclChain),
411 std::make_tuple(ExternE, AnonE, ExpectUnlinkedDeclChain),
412 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
413 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
Balazs Keric86d47b2019-09-04 14:12:18 +0000414INSTANTIATE_TEST_CASE_P(
Balázs Kérid4741c42020-02-17 14:25:16 +0100415 ParameterizedTests, ImportScopedEnumsVisibility,
416 ::testing::Combine(
417 DefaultTestValuesForRunOptions,
418 ::testing::Values(
419 std::make_tuple(ExternEC, ExternEC, ExpectLinkedDeclChain),
420 std::make_tuple(ExternEC, AnonEC, ExpectUnlinkedDeclChain),
421 std::make_tuple(AnonEC, ExternEC, ExpectUnlinkedDeclChain),
422 std::make_tuple(AnonEC, AnonEC, ExpectUnlinkedDeclChain))), );
423INSTANTIATE_TEST_CASE_P(
Balazs Keric86d47b2019-09-04 14:12:18 +0000424 ParameterizedTests, ImportTypedefNameVisibility,
425 ::testing::Combine(
426 DefaultTestValuesForRunOptions,
427 ::testing::Values(
Balazs Kericaa42792019-09-05 07:59:45 +0000428 std::make_tuple(ExternTypedef, ExternTypedef,
429 ExpectLinkedDeclChain),
430 std::make_tuple(ExternTypedef, AnonTypedef,
431 ExpectUnlinkedDeclChain),
432 std::make_tuple(AnonTypedef, ExternTypedef,
433 ExpectUnlinkedDeclChain),
434 std::make_tuple(AnonTypedef, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000435
Balazs Kericaa42792019-09-05 07:59:45 +0000436 std::make_tuple(ExternUsing, ExternUsing, ExpectLinkedDeclChain),
437 std::make_tuple(ExternUsing, AnonUsing, ExpectUnlinkedDeclChain),
438 std::make_tuple(AnonUsing, ExternUsing, ExpectUnlinkedDeclChain),
439 std::make_tuple(AnonUsing, AnonUsing, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000440
Balazs Kericaa42792019-09-05 07:59:45 +0000441 std::make_tuple(ExternUsing, ExternTypedef, ExpectLinkedDeclChain),
442 std::make_tuple(ExternUsing, AnonTypedef, ExpectUnlinkedDeclChain),
443 std::make_tuple(AnonUsing, ExternTypedef, ExpectUnlinkedDeclChain),
444 std::make_tuple(AnonUsing, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000445
Balazs Kericaa42792019-09-05 07:59:45 +0000446 std::make_tuple(ExternTypedef, ExternUsing, ExpectLinkedDeclChain),
447 std::make_tuple(ExternTypedef, AnonUsing, ExpectUnlinkedDeclChain),
448 std::make_tuple(AnonTypedef, ExternUsing, ExpectUnlinkedDeclChain),
449 std::make_tuple(AnonTypedef, AnonUsing,
450 ExpectUnlinkedDeclChain))), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000451INSTANTIATE_TEST_CASE_P(
452 ParameterizedTests, ImportFunctionTemplatesVisibility,
453 ::testing::Combine(
454 DefaultTestValuesForRunOptions,
455 ::testing::Values(
456 std::make_tuple(ExternFT, ExternFT, ExpectLinkedDeclChain),
457 std::make_tuple(ExternFT, StaticFT, ExpectUnlinkedDeclChain),
458 std::make_tuple(ExternFT, AnonFT, ExpectUnlinkedDeclChain),
459 std::make_tuple(StaticFT, ExternFT, ExpectUnlinkedDeclChain),
460 std::make_tuple(StaticFT, StaticFT, ExpectUnlinkedDeclChain),
461 std::make_tuple(StaticFT, AnonFT, ExpectUnlinkedDeclChain),
462 std::make_tuple(AnonFT, ExternFT, ExpectUnlinkedDeclChain),
463 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
464 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100465INSTANTIATE_TEST_CASE_P(
466 ParameterizedTests, ImportClassTemplatesVisibility,
467 ::testing::Combine(
468 DefaultTestValuesForRunOptions,
469 ::testing::Values(std::make_tuple(ExternCT, ExternCT, ExpectLinkedDeclChain),
470 std::make_tuple(ExternCT, AnonCT, ExpectUnlinkedDeclChain),
471 std::make_tuple(AnonCT, ExternCT, ExpectUnlinkedDeclChain),
472 std::make_tuple(AnonCT, AnonCT, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000473} // end namespace ast_matchers
474} // end namespace clang