blob: d00829f5cfee70a5923386a289503bde249a1c32 [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 {}; }";
Balazs Keric86d47b2019-09-04 14:12:18 +000072// TypedefNameDecl:
73const auto *ExternTypedef = "typedef int T;";
74const auto *AnonTypedef = "namespace { typedef int T; }";
75const auto *ExternUsing = "using T = int;";
76const auto *AnonUsing = "namespace { using T = int; }";
Balazs Kerif8a89c82019-09-13 08:03:49 +000077// FunctionTemplateDecl:
78const auto *ExternFT = "template <class> void f();";
79const auto *StaticFT = "template <class> static void f();";
80const auto *AnonFT = "namespace { template <class> void f(); }";
Balázs Kéric2f6efc2019-11-15 15:05:20 +010081// ClassTemplateDecl:
82const auto *ExternCT = "template <class> class X;";
83const auto *AnonCT = "namespace { template <class> class X; }";
Gabor Marton3c72fe12019-05-13 10:06:25 +000084
85// First value in tuple: Compile options.
86// Second value in tuple: Source code to be used in the test.
87using ImportVisibilityChainParams =
88 ::testing::WithParamInterface<std::tuple<ArgVector, const char *>>;
89// Fixture to test the redecl chain of Decls with the same visibility. Gtest
90// makes it possible to have either value-parameterized or type-parameterized
91// fixtures. However, we cannot have both value- and type-parameterized test
92// fixtures. This is a value-parameterized test fixture in the gtest sense. We
93// intend to mimic gtest's type-parameters via the PatternFactory template
94// parameter. We manually instantiate the different tests with the each types.
95template <typename PatternFactory>
96class ImportVisibilityChain
97 : public ASTImporterTestBase, public ImportVisibilityChainParams {
98protected:
99 using DeclTy = typename PatternFactory::DeclTy;
100 ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
101 std::string getCode() const { return std::get<1>(GetParam()); }
102 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
103
104 // Type-parameterized test.
105 void TypedTest_ImportChain() {
106 std::string Code = getCode() + getCode();
107 auto Pattern = getPattern();
108
Balazs Keri14d115f2019-07-15 12:16:30 +0000109 TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX14, "input0.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000110
111 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu, Pattern);
112 auto *FromD1 = LastDeclMatcher<DeclTy>().match(FromTu, Pattern);
113
Balazs Keri14d115f2019-07-15 12:16:30 +0000114 auto *ToD0 = Import(FromD0, Lang_CXX14);
115 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000116
117 EXPECT_TRUE(ToD0);
118 ASSERT_TRUE(ToD1);
119 EXPECT_NE(ToD0, ToD1);
120 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
121 }
122};
123
124// Manual instantiation of the fixture with each type.
125using ImportFunctionsVisibilityChain = ImportVisibilityChain<GetFunPattern>;
126using ImportVariablesVisibilityChain = ImportVisibilityChain<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000127using ImportClassesVisibilityChain = ImportVisibilityChain<GetClassPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000128using ImportFunctionTemplatesVisibilityChain =
129 ImportVisibilityChain<GetFunTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100130using ImportClassTemplatesVisibilityChain =
131 ImportVisibilityChain<GetClassTemplPattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000132
Balazs Keric8272192019-05-27 09:36:00 +0000133// Value-parameterized test for functions.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000134TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
135 TypedTest_ImportChain();
136}
Balazs Keric8272192019-05-27 09:36:00 +0000137// Value-parameterized test for variables.
Gabor Marton3c72fe12019-05-13 10:06:25 +0000138TEST_P(ImportVariablesVisibilityChain, ImportChain) {
139 TypedTest_ImportChain();
140}
Balazs Keric8272192019-05-27 09:36:00 +0000141// Value-parameterized test for classes.
142TEST_P(ImportClassesVisibilityChain, ImportChain) {
143 TypedTest_ImportChain();
144}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000145// Value-parameterized test for function templates.
146TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
147 TypedTest_ImportChain();
148}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100149// Value-parameterized test for class templates.
150TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
151 TypedTest_ImportChain();
152}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000153
154// Automatic instantiation of the value-parameterized tests.
155INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
156 ::testing::Combine(
157 DefaultTestValuesForRunOptions,
158 ::testing::Values(ExternF, StaticF, AnonF)), );
159INSTANTIATE_TEST_CASE_P(
160 ParameterizedTests, ImportVariablesVisibilityChain,
161 ::testing::Combine(
162 DefaultTestValuesForRunOptions,
163 // There is no point to instantiate with StaticV, because in C++ we can
164 // forward declare a variable only with the 'extern' keyword.
165 // Consequently, each fwd declared variable has external linkage. This
166 // is different in the C language where any declaration without an
167 // initializer is a tentative definition, subsequent definitions may be
168 // provided but they must have the same linkage. See also the test
169 // ImportVariableChainInC which test for this special C Lang case.
170 ::testing::Values(ExternV, AnonV)), );
Balazs Keric8272192019-05-27 09:36:00 +0000171INSTANTIATE_TEST_CASE_P(
172 ParameterizedTests, ImportClassesVisibilityChain,
173 ::testing::Combine(
174 DefaultTestValuesForRunOptions,
175 ::testing::Values(ExternC, AnonC)), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000176INSTANTIATE_TEST_CASE_P(ParameterizedTests,
177 ImportFunctionTemplatesVisibilityChain,
178 ::testing::Combine(DefaultTestValuesForRunOptions,
179 ::testing::Values(ExternFT, StaticFT,
180 AnonFT)), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100181INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
182 ::testing::Combine(DefaultTestValuesForRunOptions,
183 ::testing::Values(ExternCT,
184 AnonCT)), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000185
186// First value in tuple: Compile options.
187// Second value in tuple: Tuple with informations for the test.
188// Code for first import (or initial code), code to import, whether the `f`
189// functions are expected to be linked in a declaration chain.
190// One value of this tuple is combined with every value of compile options.
191// The test can have a single tuple as parameter only.
192using ImportVisibilityParams = ::testing::WithParamInterface<
193 std::tuple<ArgVector, std::tuple<const char *, const char *, bool>>>;
194
195template <typename PatternFactory>
196class ImportVisibility
197 : public ASTImporterTestBase,
198 public ImportVisibilityParams {
199protected:
200 using DeclTy = typename PatternFactory::DeclTy;
201 ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
202 std::string getCode0() const { return std::get<0>(std::get<1>(GetParam())); }
203 std::string getCode1() const { return std::get<1>(std::get<1>(GetParam())); }
204 bool shouldBeLinked() const { return std::get<2>(std::get<1>(GetParam())); }
205 BindableMatcher<Decl> getPattern() const { return PatternFactory()(); }
206
207 void TypedTest_ImportAfter() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000208 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
209 TranslationUnitDecl *FromTu =
210 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000211
212 auto *ToD0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
213 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
214
Balazs Keri14d115f2019-07-15 12:16:30 +0000215 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000216
217 ASSERT_TRUE(ToD0);
218 ASSERT_TRUE(ToD1);
219 EXPECT_NE(ToD0, ToD1);
220
221 if (shouldBeLinked())
222 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
223 else
224 EXPECT_FALSE(ToD1->getPreviousDecl());
225 }
226
227 void TypedTest_ImportAfterImport() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000228 TranslationUnitDecl *FromTu0 =
229 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
230 TranslationUnitDecl *FromTu1 =
231 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Gabor Marton3c72fe12019-05-13 10:06:25 +0000232 auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
233 auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000234 auto *ToD0 = Import(FromD0, Lang_CXX14);
235 auto *ToD1 = Import(FromD1, Lang_CXX14);
Gabor Marton3c72fe12019-05-13 10:06:25 +0000236 ASSERT_TRUE(ToD0);
237 ASSERT_TRUE(ToD1);
238 EXPECT_NE(ToD0, ToD1);
239 if (shouldBeLinked())
240 EXPECT_EQ(ToD1->getPreviousDecl(), ToD0);
241 else
242 EXPECT_FALSE(ToD1->getPreviousDecl());
243 }
Balazs Kerieb79b252019-07-09 11:08:18 +0000244
245 void TypedTest_ImportAfterWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000246 TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX14);
247 TranslationUnitDecl *FromTu =
248 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000249
250 auto *ToF0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern());
251 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern());
252
Balazs Keri14d115f2019-07-15 12:16:30 +0000253 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000254
255 ASSERT_TRUE(ToF0);
256 ASSERT_TRUE(ToF1);
257
258 if (shouldBeLinked())
259 EXPECT_EQ(ToF0, ToF1);
260 else
261 EXPECT_NE(ToF0, ToF1);
262
263 // We expect no (ODR) warning during the import.
264 EXPECT_EQ(0u, ToTu->getASTContext().getDiagnostics().getNumWarnings());
265 }
266
267 void TypedTest_ImportAfterImportWithMerge() {
Balazs Keri14d115f2019-07-15 12:16:30 +0000268 TranslationUnitDecl *FromTu0 =
269 getTuDecl(getCode0(), Lang_CXX14, "input0.cc");
270 TranslationUnitDecl *FromTu1 =
271 getTuDecl(getCode1(), Lang_CXX14, "input1.cc");
Balazs Kerieb79b252019-07-09 11:08:18 +0000272 auto *FromF0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern());
273 auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern());
Balazs Keri14d115f2019-07-15 12:16:30 +0000274 auto *ToF0 = Import(FromF0, Lang_CXX14);
275 auto *ToF1 = Import(FromF1, Lang_CXX14);
Balazs Kerieb79b252019-07-09 11:08:18 +0000276 ASSERT_TRUE(ToF0);
277 ASSERT_TRUE(ToF1);
278 if (shouldBeLinked())
279 EXPECT_EQ(ToF0, ToF1);
280 else
281 EXPECT_NE(ToF0, ToF1);
282
283 // We expect no (ODR) warning during the import.
284 EXPECT_EQ(0u, ToF0->getTranslationUnitDecl()
285 ->getASTContext()
286 .getDiagnostics()
287 .getNumWarnings());
288 }
Gabor Marton3c72fe12019-05-13 10:06:25 +0000289};
290using ImportFunctionsVisibility = ImportVisibility<GetFunPattern>;
291using ImportVariablesVisibility = ImportVisibility<GetVarPattern>;
Balazs Keric8272192019-05-27 09:36:00 +0000292using ImportClassesVisibility = ImportVisibility<GetClassPattern>;
Balazs Kerieb79b252019-07-09 11:08:18 +0000293using ImportEnumsVisibility = ImportVisibility<GetEnumPattern>;
Balazs Keric86d47b2019-09-04 14:12:18 +0000294using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>;
Balazs Kerif8a89c82019-09-13 08:03:49 +0000295using ImportFunctionTemplatesVisibility = ImportVisibility<GetFunTemplPattern>;
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100296using ImportClassTemplatesVisibility = ImportVisibility<GetClassTemplPattern>;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000297
298// FunctionDecl.
299TEST_P(ImportFunctionsVisibility, ImportAfter) {
300 TypedTest_ImportAfter();
301}
302TEST_P(ImportFunctionsVisibility, ImportAfterImport) {
303 TypedTest_ImportAfterImport();
304}
305// VarDecl.
306TEST_P(ImportVariablesVisibility, ImportAfter) {
307 TypedTest_ImportAfter();
308}
309TEST_P(ImportVariablesVisibility, ImportAfterImport) {
310 TypedTest_ImportAfterImport();
311}
Balazs Keric8272192019-05-27 09:36:00 +0000312// CXXRecordDecl.
313TEST_P(ImportClassesVisibility, ImportAfter) {
314 TypedTest_ImportAfter();
315}
316TEST_P(ImportClassesVisibility, ImportAfterImport) {
317 TypedTest_ImportAfterImport();
318}
Balazs Kerieb79b252019-07-09 11:08:18 +0000319// EnumDecl.
320TEST_P(ImportEnumsVisibility, ImportAfter) {
321 TypedTest_ImportAfterWithMerge();
322}
323TEST_P(ImportEnumsVisibility, ImportAfterImport) {
324 TypedTest_ImportAfterImportWithMerge();
325}
Balazs Keric86d47b2019-09-04 14:12:18 +0000326// TypedefNameDecl.
327TEST_P(ImportTypedefNameVisibility, ImportAfter) {
328 TypedTest_ImportAfterWithMerge();
329}
330TEST_P(ImportTypedefNameVisibility, ImportAfterImport) {
331 TypedTest_ImportAfterImportWithMerge();
332}
Balazs Kerif8a89c82019-09-13 08:03:49 +0000333// FunctionTemplateDecl.
334TEST_P(ImportFunctionTemplatesVisibility, ImportAfter) {
335 TypedTest_ImportAfter();
336}
337TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
338 TypedTest_ImportAfterImport();
339}
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100340// ClassTemplateDecl.
341TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
342TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
343 TypedTest_ImportAfterImport();
344}
Gabor Marton3c72fe12019-05-13 10:06:25 +0000345
Balazs Kericaa42792019-09-05 07:59:45 +0000346const bool ExpectLinkedDeclChain = true;
347const bool ExpectUnlinkedDeclChain = false;
Gabor Marton3c72fe12019-05-13 10:06:25 +0000348
349INSTANTIATE_TEST_CASE_P(
350 ParameterizedTests, ImportFunctionsVisibility,
351 ::testing::Combine(
352 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000353 ::testing::Values(
354 std::make_tuple(ExternF, ExternF, ExpectLinkedDeclChain),
355 std::make_tuple(ExternF, StaticF, ExpectUnlinkedDeclChain),
356 std::make_tuple(ExternF, AnonF, ExpectUnlinkedDeclChain),
357 std::make_tuple(StaticF, ExternF, ExpectUnlinkedDeclChain),
358 std::make_tuple(StaticF, StaticF, ExpectUnlinkedDeclChain),
359 std::make_tuple(StaticF, AnonF, ExpectUnlinkedDeclChain),
360 std::make_tuple(AnonF, ExternF, ExpectUnlinkedDeclChain),
361 std::make_tuple(AnonF, StaticF, ExpectUnlinkedDeclChain),
362 std::make_tuple(AnonF, AnonF, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000363INSTANTIATE_TEST_CASE_P(
364 ParameterizedTests, ImportVariablesVisibility,
365 ::testing::Combine(
366 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000367 ::testing::Values(
368 std::make_tuple(ExternV, ExternV, ExpectLinkedDeclChain),
369 std::make_tuple(ExternV, StaticV, ExpectUnlinkedDeclChain),
370 std::make_tuple(ExternV, AnonV, ExpectUnlinkedDeclChain),
371 std::make_tuple(StaticV, ExternV, ExpectUnlinkedDeclChain),
372 std::make_tuple(StaticV, StaticV, ExpectUnlinkedDeclChain),
373 std::make_tuple(StaticV, AnonV, ExpectUnlinkedDeclChain),
374 std::make_tuple(AnonV, ExternV, ExpectUnlinkedDeclChain),
375 std::make_tuple(AnonV, StaticV, ExpectUnlinkedDeclChain),
376 std::make_tuple(AnonV, AnonV, ExpectUnlinkedDeclChain))), );
Balazs Keric8272192019-05-27 09:36:00 +0000377INSTANTIATE_TEST_CASE_P(
378 ParameterizedTests, ImportClassesVisibility,
379 ::testing::Combine(
380 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000381 ::testing::Values(
382 std::make_tuple(ExternC, ExternC, ExpectLinkedDeclChain),
383 std::make_tuple(ExternC, AnonC, ExpectUnlinkedDeclChain),
384 std::make_tuple(AnonC, ExternC, ExpectUnlinkedDeclChain),
385 std::make_tuple(AnonC, AnonC, ExpectUnlinkedDeclChain))), );
Balazs Kerieb79b252019-07-09 11:08:18 +0000386INSTANTIATE_TEST_CASE_P(
387 ParameterizedTests, ImportEnumsVisibility,
388 ::testing::Combine(
389 DefaultTestValuesForRunOptions,
Balazs Kericaa42792019-09-05 07:59:45 +0000390 ::testing::Values(
391 std::make_tuple(ExternE, ExternE, ExpectLinkedDeclChain),
392 std::make_tuple(ExternE, AnonE, ExpectUnlinkedDeclChain),
393 std::make_tuple(AnonE, ExternE, ExpectUnlinkedDeclChain),
394 std::make_tuple(AnonE, AnonE, ExpectUnlinkedDeclChain))), );
Balazs Keric86d47b2019-09-04 14:12:18 +0000395INSTANTIATE_TEST_CASE_P(
396 ParameterizedTests, ImportTypedefNameVisibility,
397 ::testing::Combine(
398 DefaultTestValuesForRunOptions,
399 ::testing::Values(
Balazs Kericaa42792019-09-05 07:59:45 +0000400 std::make_tuple(ExternTypedef, ExternTypedef,
401 ExpectLinkedDeclChain),
402 std::make_tuple(ExternTypedef, AnonTypedef,
403 ExpectUnlinkedDeclChain),
404 std::make_tuple(AnonTypedef, ExternTypedef,
405 ExpectUnlinkedDeclChain),
406 std::make_tuple(AnonTypedef, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000407
Balazs Kericaa42792019-09-05 07:59:45 +0000408 std::make_tuple(ExternUsing, ExternUsing, ExpectLinkedDeclChain),
409 std::make_tuple(ExternUsing, AnonUsing, ExpectUnlinkedDeclChain),
410 std::make_tuple(AnonUsing, ExternUsing, ExpectUnlinkedDeclChain),
411 std::make_tuple(AnonUsing, AnonUsing, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000412
Balazs Kericaa42792019-09-05 07:59:45 +0000413 std::make_tuple(ExternUsing, ExternTypedef, ExpectLinkedDeclChain),
414 std::make_tuple(ExternUsing, AnonTypedef, ExpectUnlinkedDeclChain),
415 std::make_tuple(AnonUsing, ExternTypedef, ExpectUnlinkedDeclChain),
416 std::make_tuple(AnonUsing, AnonTypedef, ExpectUnlinkedDeclChain),
Balazs Keric86d47b2019-09-04 14:12:18 +0000417
Balazs Kericaa42792019-09-05 07:59:45 +0000418 std::make_tuple(ExternTypedef, ExternUsing, ExpectLinkedDeclChain),
419 std::make_tuple(ExternTypedef, AnonUsing, ExpectUnlinkedDeclChain),
420 std::make_tuple(AnonTypedef, ExternUsing, ExpectUnlinkedDeclChain),
421 std::make_tuple(AnonTypedef, AnonUsing,
422 ExpectUnlinkedDeclChain))), );
Balazs Kerif8a89c82019-09-13 08:03:49 +0000423INSTANTIATE_TEST_CASE_P(
424 ParameterizedTests, ImportFunctionTemplatesVisibility,
425 ::testing::Combine(
426 DefaultTestValuesForRunOptions,
427 ::testing::Values(
428 std::make_tuple(ExternFT, ExternFT, ExpectLinkedDeclChain),
429 std::make_tuple(ExternFT, StaticFT, ExpectUnlinkedDeclChain),
430 std::make_tuple(ExternFT, AnonFT, ExpectUnlinkedDeclChain),
431 std::make_tuple(StaticFT, ExternFT, ExpectUnlinkedDeclChain),
432 std::make_tuple(StaticFT, StaticFT, ExpectUnlinkedDeclChain),
433 std::make_tuple(StaticFT, AnonFT, ExpectUnlinkedDeclChain),
434 std::make_tuple(AnonFT, ExternFT, ExpectUnlinkedDeclChain),
435 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
436 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
Balázs Kéric2f6efc2019-11-15 15:05:20 +0100437INSTANTIATE_TEST_CASE_P(
438 ParameterizedTests, ImportClassTemplatesVisibility,
439 ::testing::Combine(
440 DefaultTestValuesForRunOptions,
441 ::testing::Values(std::make_tuple(ExternCT, ExternCT, ExpectLinkedDeclChain),
442 std::make_tuple(ExternCT, AnonCT, ExpectUnlinkedDeclChain),
443 std::make_tuple(AnonCT, ExternCT, ExpectUnlinkedDeclChain),
444 std::make_tuple(AnonCT, AnonCT, ExpectUnlinkedDeclChain))), );
Gabor Marton3c72fe12019-05-13 10:06:25 +0000445} // end namespace ast_matchers
446} // end namespace clang