1 | //===- 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 | |
20 | namespace clang { |
21 | namespace ast_matchers { |
22 | |
23 | using internal::BindableMatcher; |
24 | |
25 | // Type parameters for type-parameterized test fixtures. |
26 | struct GetFunPattern { |
27 | using DeclTy = FunctionDecl; |
28 | BindableMatcher<Decl> operator()() { return functionDecl(hasName(Name: "f" )); } |
29 | }; |
30 | struct GetVarPattern { |
31 | using DeclTy = VarDecl; |
32 | BindableMatcher<Decl> operator()() { return varDecl(hasName(Name: "v" )); } |
33 | }; |
34 | struct GetClassPattern { |
35 | using DeclTy = CXXRecordDecl; |
36 | BindableMatcher<Decl> operator()() { return cxxRecordDecl(hasName(Name: "X" )); } |
37 | }; |
38 | struct GetEnumPattern { |
39 | using DeclTy = EnumDecl; |
40 | BindableMatcher<Decl> operator()() { return enumDecl(hasName(Name: "E" )); } |
41 | }; |
42 | struct GetTypedefNamePattern { |
43 | using DeclTy = TypedefNameDecl; |
44 | BindableMatcher<Decl> operator()() { return typedefNameDecl(hasName(Name: "T" )); } |
45 | }; |
46 | struct GetFunTemplPattern { |
47 | using DeclTy = FunctionTemplateDecl; |
48 | BindableMatcher<Decl> operator()() { |
49 | return functionTemplateDecl(hasName(Name: "f" )); |
50 | } |
51 | }; |
52 | struct GetVarTemplPattern { |
53 | using DeclTy = VarTemplateDecl; |
54 | BindableMatcher<Decl> operator()() { |
55 | return namedDecl(hasName(Name: "v" ), has(templateTypeParmDecl())); |
56 | } |
57 | }; |
58 | struct GetClassTemplPattern { |
59 | using DeclTy = ClassTemplateDecl; |
60 | BindableMatcher<Decl> operator()() { return classTemplateDecl(hasName(Name: "X" )); } |
61 | }; |
62 | |
63 | // Values for the value-parameterized test fixtures. |
64 | // FunctionDecl: |
65 | const auto *ExternF = "void f();" ; |
66 | const auto *StaticF = "static void f();" ; |
67 | const auto *AnonF = "namespace { void f(); }" ; |
68 | // VarDecl: |
69 | const auto *ExternV = "extern int v;" ; |
70 | const auto *StaticV = "static int v;" ; |
71 | const auto *AnonV = "namespace { extern int v; }" ; |
72 | // CXXRecordDecl: |
73 | const auto *ExternC = "class X;" ; |
74 | const auto *AnonC = "namespace { class X; }" ; |
75 | // EnumDecl: |
76 | const auto *ExternE = "enum E {};" ; |
77 | const auto *AnonE = "namespace { enum E {}; }" ; |
78 | const auto *ExternEC = "enum class E;" ; |
79 | const auto *AnonEC = "namespace { enum class E; }" ; |
80 | // TypedefNameDecl: |
81 | const auto *ExternTypedef = "typedef int T;" ; |
82 | const auto *AnonTypedef = "namespace { typedef int T; }" ; |
83 | const auto *ExternUsing = "using T = int;" ; |
84 | const auto *AnonUsing = "namespace { using T = int; }" ; |
85 | // FunctionTemplateDecl: |
86 | const auto *ExternFT = "template <class> void f();" ; |
87 | const auto *StaticFT = "template <class> static void f();" ; |
88 | const auto *AnonFT = "namespace { template <class> void f(); }" ; |
89 | // VarTemplateDecl: |
90 | const auto *ExternVT = "template <class> extern int v;" ; |
91 | const auto *StaticVT = "template <class> static int v;" ; |
92 | const auto *AnonVT = "namespace { template <class> extern int v; }" ; |
93 | // ClassTemplateDecl: |
94 | const auto *ExternCT = "template <class> class X;" ; |
95 | const auto *AnonCT = "namespace { template <class> class X; }" ; |
96 | |
97 | // First value in tuple: Compile options. |
98 | // Second value in tuple: Source code to be used in the test. |
99 | using ImportVisibilityChainParams = ::testing::WithParamInterface< |
100 | std::tuple<std::vector<std::string>, 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. |
107 | template <typename PatternFactory> |
108 | class ImportVisibilityChain |
109 | : public ASTImporterTestBase, public ImportVisibilityChainParams { |
110 | protected: |
111 | using DeclTy = typename PatternFactory::DeclTy; |
112 | std::vector<std::string> () const override { |
113 | return std::get<0>(t: GetParam()); |
114 | } |
115 | std::string getCode() const { return std::get<1>(t: 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 | |
123 | TranslationUnitDecl *FromTu = getTuDecl(SrcCode: Code, Lang: Lang_CXX14, FileName: "input0.cc" ); |
124 | |
125 | auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu, Pattern); |
126 | auto *FromD1 = LastDeclMatcher<DeclTy>().match(FromTu, Pattern); |
127 | |
128 | auto *ToD0 = Import(FromD0, Lang_CXX14); |
129 | auto *ToD1 = Import(FromD1, Lang_CXX14); |
130 | |
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. |
139 | using ImportFunctionsVisibilityChain = ImportVisibilityChain<GetFunPattern>; |
140 | using ImportVariablesVisibilityChain = ImportVisibilityChain<GetVarPattern>; |
141 | using ImportClassesVisibilityChain = ImportVisibilityChain<GetClassPattern>; |
142 | using ImportScopedEnumsVisibilityChain = ImportVisibilityChain<GetEnumPattern>; |
143 | using ImportFunctionTemplatesVisibilityChain = |
144 | ImportVisibilityChain<GetFunTemplPattern>; |
145 | using ImportVariableTemplatesVisibilityChain = |
146 | ImportVisibilityChain<GetVarTemplPattern>; |
147 | using ImportClassTemplatesVisibilityChain = |
148 | ImportVisibilityChain<GetClassTemplPattern>; |
149 | |
150 | // Value-parameterized test for functions. |
151 | TEST_P(ImportFunctionsVisibilityChain, ImportChain) { |
152 | TypedTest_ImportChain(); |
153 | } |
154 | // Value-parameterized test for variables. |
155 | TEST_P(ImportVariablesVisibilityChain, ImportChain) { |
156 | TypedTest_ImportChain(); |
157 | } |
158 | // Value-parameterized test for classes. |
159 | TEST_P(ImportClassesVisibilityChain, ImportChain) { |
160 | TypedTest_ImportChain(); |
161 | } |
162 | // Value-parameterized test for scoped enums. |
163 | TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) { |
164 | TypedTest_ImportChain(); |
165 | } |
166 | // Value-parameterized test for function templates. |
167 | TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) { |
168 | TypedTest_ImportChain(); |
169 | } |
170 | // Value-parameterized test for variable templates. |
171 | TEST_P(ImportVariableTemplatesVisibilityChain, ImportChain) { |
172 | TypedTest_ImportChain(); |
173 | } |
174 | // Value-parameterized test for class templates. |
175 | TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) { |
176 | TypedTest_ImportChain(); |
177 | } |
178 | |
179 | // Automatic instantiation of the value-parameterized tests. |
180 | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportFunctionsVisibilityChain, |
181 | ::testing::Combine(DefaultTestValuesForRunOptions, |
182 | ::testing::Values(ExternF, StaticF, |
183 | AnonF))); |
184 | INSTANTIATE_TEST_SUITE_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)) ); |
196 | INSTANTIATE_TEST_SUITE_P( |
197 | ParameterizedTests, ImportClassesVisibilityChain, |
198 | ::testing::Combine( |
199 | DefaultTestValuesForRunOptions, |
200 | ::testing::Values(ExternC, AnonC)) ); |
201 | INSTANTIATE_TEST_SUITE_P( |
202 | ParameterizedTests, ImportScopedEnumsVisibilityChain, |
203 | ::testing::Combine( |
204 | DefaultTestValuesForRunOptions, |
205 | ::testing::Values(ExternEC, AnonEC)) ); |
206 | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, |
207 | ImportFunctionTemplatesVisibilityChain, |
208 | ::testing::Combine(DefaultTestValuesForRunOptions, |
209 | ::testing::Values(ExternFT, StaticFT, |
210 | AnonFT)) ); |
211 | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, |
212 | ImportVariableTemplatesVisibilityChain, |
213 | ::testing::Combine(DefaultTestValuesForRunOptions, |
214 | ::testing::Values(ExternVT, |
215 | AnonVT)) ); |
216 | INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain, |
217 | ::testing::Combine(DefaultTestValuesForRunOptions, |
218 | ::testing::Values(ExternCT, |
219 | AnonCT)) ); |
220 | |
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. |
227 | using ImportVisibilityParams = ::testing::WithParamInterface<std::tuple< |
228 | std::vector<std::string>, std::tuple<const char *, const char *, bool>>>; |
229 | |
230 | template <typename PatternFactory> |
231 | class ImportVisibility |
232 | : public ASTImporterTestBase, |
233 | public ImportVisibilityParams { |
234 | protected: |
235 | using DeclTy = typename PatternFactory::DeclTy; |
236 | std::vector<std::string> () const override { |
237 | return std::get<0>(t: GetParam()); |
238 | } |
239 | std::string getCode0() const { return std::get<0>(t: std::get<1>(t: GetParam())); } |
240 | std::string getCode1() const { return std::get<1>(t: std::get<1>(t: GetParam())); } |
241 | bool shouldBeLinked() const { return std::get<2>(t: std::get<1>(t: GetParam())); } |
242 | BindableMatcher<Decl> getPattern() const { return PatternFactory()(); } |
243 | |
244 | void TypedTest_ImportAfter() { |
245 | TranslationUnitDecl *ToTu = getToTuDecl(ToSrcCode: getCode0(), ToLang: Lang_CXX14); |
246 | TranslationUnitDecl *FromTu = |
247 | getTuDecl(SrcCode: getCode1(), Lang: Lang_CXX14, FileName: "input1.cc" ); |
248 | |
249 | auto *ToD0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern()); |
250 | auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern()); |
251 | |
252 | auto *ToD1 = Import(FromD1, Lang_CXX14); |
253 | |
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() { |
265 | TranslationUnitDecl *FromTu0 = |
266 | getTuDecl(SrcCode: getCode0(), Lang: Lang_CXX14, FileName: "input0.cc" ); |
267 | TranslationUnitDecl *FromTu1 = |
268 | getTuDecl(SrcCode: getCode1(), Lang: Lang_CXX14, FileName: "input1.cc" ); |
269 | auto *FromD0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern()); |
270 | auto *FromD1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern()); |
271 | auto *ToD0 = Import(FromD0, Lang_CXX14); |
272 | auto *ToD1 = Import(FromD1, Lang_CXX14); |
273 | 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 | } |
281 | |
282 | void TypedTest_ImportAfterWithMerge() { |
283 | TranslationUnitDecl *ToTu = getToTuDecl(ToSrcCode: getCode0(), ToLang: Lang_CXX14); |
284 | TranslationUnitDecl *FromTu = |
285 | getTuDecl(SrcCode: getCode1(), Lang: Lang_CXX14, FileName: "input1.cc" ); |
286 | |
287 | auto *ToF0 = FirstDeclMatcher<DeclTy>().match(ToTu, getPattern()); |
288 | auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu, getPattern()); |
289 | |
290 | auto *ToF1 = Import(FromF1, Lang_CXX14); |
291 | |
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() { |
305 | TranslationUnitDecl *FromTu0 = |
306 | getTuDecl(SrcCode: getCode0(), Lang: Lang_CXX14, FileName: "input0.cc" ); |
307 | TranslationUnitDecl *FromTu1 = |
308 | getTuDecl(SrcCode: getCode1(), Lang: Lang_CXX14, FileName: "input1.cc" ); |
309 | auto *FromF0 = FirstDeclMatcher<DeclTy>().match(FromTu0, getPattern()); |
310 | auto *FromF1 = FirstDeclMatcher<DeclTy>().match(FromTu1, getPattern()); |
311 | auto *ToF0 = Import(FromF0, Lang_CXX14); |
312 | auto *ToF1 = Import(FromF1, Lang_CXX14); |
313 | 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 | } |
326 | }; |
327 | using ImportFunctionsVisibility = ImportVisibility<GetFunPattern>; |
328 | using ImportVariablesVisibility = ImportVisibility<GetVarPattern>; |
329 | using ImportClassesVisibility = ImportVisibility<GetClassPattern>; |
330 | using ImportEnumsVisibility = ImportVisibility<GetEnumPattern>; |
331 | using ImportScopedEnumsVisibility = ImportVisibility<GetEnumPattern>; |
332 | using ImportTypedefNameVisibility = ImportVisibility<GetTypedefNamePattern>; |
333 | using ImportFunctionTemplatesVisibility = ImportVisibility<GetFunTemplPattern>; |
334 | using ImportVariableTemplatesVisibility = ImportVisibility<GetVarTemplPattern>; |
335 | using ImportClassTemplatesVisibility = ImportVisibility<GetClassTemplPattern>; |
336 | |
337 | // FunctionDecl. |
338 | TEST_P(ImportFunctionsVisibility, ImportAfter) { |
339 | TypedTest_ImportAfter(); |
340 | } |
341 | TEST_P(ImportFunctionsVisibility, ImportAfterImport) { |
342 | TypedTest_ImportAfterImport(); |
343 | } |
344 | // VarDecl. |
345 | TEST_P(ImportVariablesVisibility, ImportAfter) { |
346 | TypedTest_ImportAfter(); |
347 | } |
348 | TEST_P(ImportVariablesVisibility, ImportAfterImport) { |
349 | TypedTest_ImportAfterImport(); |
350 | } |
351 | // CXXRecordDecl. |
352 | TEST_P(ImportClassesVisibility, ImportAfter) { |
353 | TypedTest_ImportAfter(); |
354 | } |
355 | TEST_P(ImportClassesVisibility, ImportAfterImport) { |
356 | TypedTest_ImportAfterImport(); |
357 | } |
358 | // EnumDecl. |
359 | TEST_P(ImportEnumsVisibility, ImportAfter) { |
360 | TypedTest_ImportAfterWithMerge(); |
361 | } |
362 | TEST_P(ImportEnumsVisibility, ImportAfterImport) { |
363 | TypedTest_ImportAfterImportWithMerge(); |
364 | } |
365 | TEST_P(ImportScopedEnumsVisibility, ImportAfter) { |
366 | TypedTest_ImportAfter(); |
367 | } |
368 | TEST_P(ImportScopedEnumsVisibility, ImportAfterImport) { |
369 | TypedTest_ImportAfterImport(); |
370 | } |
371 | // TypedefNameDecl. |
372 | TEST_P(ImportTypedefNameVisibility, ImportAfter) { |
373 | TypedTest_ImportAfterWithMerge(); |
374 | } |
375 | TEST_P(ImportTypedefNameVisibility, ImportAfterImport) { |
376 | TypedTest_ImportAfterImportWithMerge(); |
377 | } |
378 | // FunctionTemplateDecl. |
379 | TEST_P(ImportFunctionTemplatesVisibility, ImportAfter) { |
380 | TypedTest_ImportAfter(); |
381 | } |
382 | TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) { |
383 | TypedTest_ImportAfterImport(); |
384 | } |
385 | // VarTemplateDecl. |
386 | TEST_P(ImportVariableTemplatesVisibility, ImportAfter) { |
387 | TypedTest_ImportAfter(); |
388 | } |
389 | TEST_P(ImportVariableTemplatesVisibility, ImportAfterImport) { |
390 | TypedTest_ImportAfterImport(); |
391 | } |
392 | // ClassTemplateDecl. |
393 | TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); } |
394 | TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) { |
395 | TypedTest_ImportAfterImport(); |
396 | } |
397 | |
398 | const bool ExpectLinkedDeclChain = true; |
399 | const bool ExpectUnlinkedDeclChain = false; |
400 | |
401 | INSTANTIATE_TEST_SUITE_P( |
402 | ParameterizedTests, ImportFunctionsVisibility, |
403 | ::testing::Combine( |
404 | DefaultTestValuesForRunOptions, |
405 | ::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))) ); |
415 | INSTANTIATE_TEST_SUITE_P( |
416 | ParameterizedTests, ImportVariablesVisibility, |
417 | ::testing::Combine( |
418 | DefaultTestValuesForRunOptions, |
419 | ::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))) ); |
429 | INSTANTIATE_TEST_SUITE_P( |
430 | ParameterizedTests, ImportClassesVisibility, |
431 | ::testing::Combine( |
432 | DefaultTestValuesForRunOptions, |
433 | ::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))) ); |
438 | INSTANTIATE_TEST_SUITE_P( |
439 | ParameterizedTests, ImportEnumsVisibility, |
440 | ::testing::Combine( |
441 | DefaultTestValuesForRunOptions, |
442 | ::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))) ); |
447 | INSTANTIATE_TEST_SUITE_P( |
448 | 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))) ); |
456 | INSTANTIATE_TEST_SUITE_P( |
457 | ParameterizedTests, ImportTypedefNameVisibility, |
458 | ::testing::Combine( |
459 | DefaultTestValuesForRunOptions, |
460 | ::testing::Values( |
461 | 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), |
468 | |
469 | 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), |
473 | |
474 | 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), |
478 | |
479 | 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))) ); |
484 | INSTANTIATE_TEST_SUITE_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))) ); |
498 | INSTANTIATE_TEST_SUITE_P( |
499 | 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))) ); |
512 | INSTANTIATE_TEST_SUITE_P( |
513 | 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))) ); |
520 | } // end namespace ast_matchers |
521 | } // end namespace clang |
522 | |