1 //===- ASTImporterODRStrategiesTest.cpp -----------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Type-parameterized tests to verify the import behaviour in case of ODR
12 //===----------------------------------------------------------------------===//
14 #include "ASTImporterFixtures.h"
17 namespace ast_matchers
{
19 using internal::BindableMatcher
;
21 // DeclTy: Type of the Decl to check.
22 // Prototype: "Prototype" (forward declaration) of the Decl.
23 // Definition: A definition for the Prototype.
24 // ConflictingPrototype: A prototype with the same name but different
26 // ConflictingDefinition: A different definition for Prototype.
27 // ConflictingProtoDef: A definition for ConflictingPrototype.
28 // getPattern: Return a matcher that matches any of Prototype, Definition,
29 // ConflictingPrototype, ConflictingDefinition, ConflictingProtoDef.
32 using DeclTy
= FunctionDecl
;
33 static constexpr auto *Prototype
= "void X(int);";
34 static constexpr auto *ConflictingPrototype
= "void X(double);";
35 static constexpr auto *Definition
= "void X(int a) {}";
36 static constexpr auto *ConflictingDefinition
= "void X(double a) {}";
37 BindableMatcher
<Decl
> getPattern() {
38 return functionDecl(hasName("X"), unless(isImplicit()));
40 TestLanguage
getLang() { return Lang_C99
; }
44 using DeclTy
= TypedefNameDecl
;
45 static constexpr auto *Definition
= "typedef int X;";
46 static constexpr auto *ConflictingDefinition
= "typedef double X;";
47 BindableMatcher
<Decl
> getPattern() { return typedefNameDecl(hasName("X")); }
48 TestLanguage
getLang() { return Lang_CXX03
; }
52 using DeclTy
= TypedefNameDecl
;
53 static constexpr auto *Definition
= "using X = int;";
54 static constexpr auto *ConflictingDefinition
= "using X = double;";
55 BindableMatcher
<Decl
> getPattern() { return typedefNameDecl(hasName("X")); }
56 TestLanguage
getLang() { return Lang_CXX11
; }
60 using DeclTy
= EnumDecl
;
61 static constexpr auto *Definition
= "enum X { a, b };";
62 static constexpr auto *ConflictingDefinition
= "enum X { a, b, c };";
63 BindableMatcher
<Decl
> getPattern() { return enumDecl(hasName("X")); }
64 TestLanguage
getLang() { return Lang_CXX03
; }
68 using DeclTy
= EnumDecl
;
69 static constexpr auto *Definition
= "enum class X { a, b };";
70 static constexpr auto *ConflictingDefinition
= "enum class X { a, b, c };";
71 BindableMatcher
<Decl
> getPattern() { return enumDecl(hasName("X")); }
72 TestLanguage
getLang() { return Lang_CXX11
; }
76 using DeclTy
= EnumConstantDecl
;
77 static constexpr auto *Definition
= "enum E { X = 0 };";
78 static constexpr auto *ConflictingDefinition
= "enum E { X = 1 };";
79 BindableMatcher
<Decl
> getPattern() { return enumConstantDecl(hasName("X")); }
80 TestLanguage
getLang() { return Lang_CXX03
; }
84 using DeclTy
= CXXRecordDecl
;
85 static constexpr auto *Prototype
= "class X;";
86 static constexpr auto *Definition
= "class X {};";
87 static constexpr auto *ConflictingDefinition
= "class X { int A; };";
88 BindableMatcher
<Decl
> getPattern() {
89 return cxxRecordDecl(hasName("X"), unless(isImplicit()));
91 TestLanguage
getLang() { return Lang_CXX03
; }
95 using DeclTy
= VarDecl
;
96 static constexpr auto *Prototype
= "extern int X;";
97 static constexpr auto *ConflictingPrototype
= "extern float X;";
98 static constexpr auto *Definition
= "int X;";
99 static constexpr auto *ConflictingDefinition
= "float X;";
100 BindableMatcher
<Decl
> getPattern() { return varDecl(hasName("X")); }
101 TestLanguage
getLang() { return Lang_CXX03
; }
104 struct ClassTemplate
{
105 using DeclTy
= ClassTemplateDecl
;
106 static constexpr auto *Prototype
= "template <class> class X;";
107 static constexpr auto *ConflictingPrototype
= "template <int> class X;";
108 static constexpr auto *Definition
= "template <class> class X {};";
109 static constexpr auto *ConflictingDefinition
=
110 "template <class> class X { int A; };";
111 static constexpr auto *ConflictingProtoDef
= "template <int> class X { };";
112 BindableMatcher
<Decl
> getPattern() {
113 return classTemplateDecl(hasName("X"), unless(isImplicit()));
115 TestLanguage
getLang() { return Lang_CXX03
; }
118 struct FunctionTemplate
{
119 using DeclTy
= FunctionTemplateDecl
;
120 static constexpr auto *Definition0
=
125 // This is actually not a conflicting definition, but another primary template.
126 static constexpr auto *Definition1
=
131 BindableMatcher
<Decl
> getPattern() {
132 return functionTemplateDecl(hasName("X"), unless(isImplicit()));
134 static std::string
getDef0() { return Definition0
; }
135 static std::string
getDef1() { return Definition1
; }
136 TestLanguage
getLang() { return Lang_CXX03
; }
139 static const internal::VariadicDynCastAllOfMatcher
<Decl
, VarTemplateDecl
>
143 using DeclTy
= VarTemplateDecl
;
144 static constexpr auto *Definition
=
149 static constexpr auto *ConflictingDefinition
=
154 BindableMatcher
<Decl
> getPattern() { return varTemplateDecl(hasName("X")); }
155 TestLanguage
getLang() { return Lang_CXX14
; }
158 struct ClassTemplateSpec
{
159 using DeclTy
= ClassTemplateSpecializationDecl
;
160 static constexpr auto *Prototype
=
162 template <class T> class X;
163 template <> class X<int>;
165 static constexpr auto *Definition
=
167 template <class T> class X;
168 template <> class X<int> {};
170 static constexpr auto *ConflictingDefinition
=
172 template <class T> class X;
173 template <> class X<int> { int A; };
175 BindableMatcher
<Decl
> getPattern() {
176 return classTemplateSpecializationDecl(hasName("X"), unless(isImplicit()));
178 TestLanguage
getLang() { return Lang_CXX03
; }
181 // Function template specializations are all "full" specializations.
182 // Structural equivalency does not check the body of functions, so we cannot
183 // create conflicting function template specializations.
184 struct FunctionTemplateSpec
{
185 using DeclTy
= FunctionDecl
;
187 static constexpr auto *Definition0
=
191 template <> void X(int a) {};
194 // This is actually not a conflicting definition, but another full
196 // Thus, during the import we would create a new specialization with a
197 // different type argument.
198 static constexpr auto *Definition1
=
202 template <> void X(double a) {};
205 BindableMatcher
<Decl
> getPattern() {
206 return functionDecl(hasName("X"), isExplicitTemplateSpecialization(),
207 unless(isImplicit()));
209 static std::string
getDef0() { return Definition0
; }
210 static std::string
getDef1() { return Definition1
; }
211 TestLanguage
getLang() { return Lang_CXX03
; }
214 static const internal::VariadicDynCastAllOfMatcher
<
215 Decl
, VarTemplateSpecializationDecl
>
216 varTemplateSpecializationDecl
;
218 struct VarTemplateSpec
{
219 using DeclTy
= VarTemplateSpecializationDecl
;
220 static constexpr auto *Definition
=
222 template <class T> T X = 0;
223 template <> int X<int> = 0;
225 static constexpr auto *ConflictingDefinition
=
227 template <class T> T X = 0;
228 template <> float X<int> = 1.0;
230 BindableMatcher
<Decl
> getPattern() {
231 return varTemplateSpecializationDecl(hasName("X"), unless(isImplicit()));
233 TestLanguage
getLang() { return Lang_CXX14
; }
236 template <typename TypeParam
, ASTImporter::ODRHandlingType ODRHandlingParam
>
237 struct ODRViolation
: ASTImporterOptionSpecificTestBase
{
239 using DeclTy
= typename
TypeParam::DeclTy
;
241 ODRViolation() { ODRHandling
= ODRHandlingParam
; }
243 static std::string
getPrototype() { return TypeParam::Prototype
; }
244 static std::string
getConflictingPrototype() {
245 return TypeParam::ConflictingPrototype
;
247 static std::string
getDefinition() { return TypeParam::Definition
; }
248 static std::string
getConflictingDefinition() {
249 return TypeParam::ConflictingDefinition
;
251 static std::string
getConflictingProtoDef() {
252 return TypeParam::ConflictingProtoDef
;
254 static BindableMatcher
<Decl
> getPattern() { return TypeParam().getPattern(); }
255 static TestLanguage
getLang() { return TypeParam().getLang(); }
257 template <std::string (*ToTUContent
)(), std::string (*FromTUContent
)(),
258 void (*ResultChecker
)(llvm::Expected
<Decl
*> &, Decl
*, Decl
*)>
259 void TypedTest_ImportAfter() {
260 Decl
*ToTU
= getToTuDecl(ToTUContent(), getLang());
261 auto *ToD
= FirstDeclMatcher
<DeclTy
>().match(ToTU
, getPattern());
263 Decl
*FromTU
= getTuDecl(FromTUContent(), getLang());
264 auto *FromD
= FirstDeclMatcher
<DeclTy
>().match(FromTU
, getPattern());
266 auto Result
= importOrError(FromD
, getLang());
268 ResultChecker(Result
, ToTU
, ToD
);
271 // Check that a Decl has been successfully imported into a standalone redecl
273 static void CheckImportedAsNew(llvm::Expected
<Decl
*> &Result
, Decl
*ToTU
,
275 ASSERT_TRUE(isSuccess(Result
));
276 Decl
*ImportedD
= *Result
;
277 ASSERT_TRUE(ImportedD
);
278 EXPECT_NE(ImportedD
, ToD
);
279 EXPECT_EQ(DeclCounter
<DeclTy
>().match(ToTU
, getPattern()), 2u);
281 // There may be a hidden fwd spec decl before a function spec decl.
282 if (auto *ImportedF
= dyn_cast
<FunctionDecl
>(ImportedD
))
283 if (ImportedF
->getTemplatedKind() ==
284 FunctionDecl::TK_FunctionTemplateSpecialization
)
287 EXPECT_FALSE(ImportedD
->getPreviousDecl());
290 // Check that a Decl was not imported because of NameConflict.
291 static void CheckImportNameConflict(llvm::Expected
<Decl
*> &Result
,
292 Decl
*ToTU
, Decl
*ToD
) {
293 EXPECT_TRUE(isImportError(Result
, ASTImportError::NameConflict
));
294 EXPECT_EQ(DeclCounter
<DeclTy
>().match(ToTU
, getPattern()), 1u);
297 // Check that a Decl was not imported because lookup found the same decl.
298 static void CheckImportFoundExisting(llvm::Expected
<Decl
*> &Result
,
299 Decl
*ToTU
, Decl
*ToD
) {
300 ASSERT_TRUE(isSuccess(Result
));
301 EXPECT_EQ(DeclCounter
<DeclTy
>().match(ToTU
, getPattern()), 1u);
304 void TypedTest_ImportConflictingDefAfterDef() {
305 TypedTest_ImportAfter
<getDefinition
, getConflictingDefinition
,
306 CheckImportedAsNew
>();
308 void TypedTest_ImportConflictingProtoAfterProto() {
309 TypedTest_ImportAfter
<getPrototype
, getConflictingPrototype
,
310 CheckImportedAsNew
>();
312 void TypedTest_ImportConflictingProtoAfterDef() {
313 TypedTest_ImportAfter
<getDefinition
, getConflictingPrototype
,
314 CheckImportedAsNew
>();
316 void TypedTest_ImportConflictingDefAfterProto() {
317 TypedTest_ImportAfter
<getConflictingPrototype
, getDefinition
,
318 CheckImportedAsNew
>();
320 void TypedTest_ImportConflictingProtoDefAfterProto() {
321 TypedTest_ImportAfter
<getPrototype
, getConflictingProtoDef
,
322 CheckImportedAsNew
>();
324 void TypedTest_ImportConflictingProtoAfterProtoDef() {
325 TypedTest_ImportAfter
<getConflictingProtoDef
, getPrototype
,
326 CheckImportedAsNew
>();
328 void TypedTest_ImportConflictingProtoDefAfterDef() {
329 TypedTest_ImportAfter
<getDefinition
, getConflictingProtoDef
,
330 CheckImportedAsNew
>();
332 void TypedTest_ImportConflictingDefAfterProtoDef() {
333 TypedTest_ImportAfter
<getConflictingProtoDef
, getDefinition
,
334 CheckImportedAsNew
>();
337 void TypedTest_DontImportConflictingProtoAfterProto() {
338 TypedTest_ImportAfter
<getPrototype
, getConflictingPrototype
,
339 CheckImportNameConflict
>();
341 void TypedTest_DontImportConflictingDefAfterDef() {
342 TypedTest_ImportAfter
<getDefinition
, getConflictingDefinition
,
343 CheckImportNameConflict
>();
345 void TypedTest_DontImportConflictingProtoAfterDef() {
346 TypedTest_ImportAfter
<getDefinition
, getConflictingPrototype
,
347 CheckImportNameConflict
>();
349 void TypedTest_DontImportConflictingDefAfterProto() {
350 TypedTest_ImportAfter
<getConflictingPrototype
, getDefinition
,
351 CheckImportNameConflict
>();
353 void TypedTest_DontImportConflictingProtoDefAfterProto() {
354 TypedTest_ImportAfter
<getPrototype
, getConflictingProtoDef
,
355 CheckImportNameConflict
>();
357 void TypedTest_DontImportConflictingProtoAfterProtoDef() {
358 TypedTest_ImportAfter
<getConflictingProtoDef
, getPrototype
,
359 CheckImportNameConflict
>();
361 void TypedTest_DontImportConflictingProtoDefAfterDef() {
362 TypedTest_ImportAfter
<getDefinition
, getConflictingProtoDef
,
363 CheckImportNameConflict
>();
365 void TypedTest_DontImportConflictingDefAfterProtoDef() {
366 TypedTest_ImportAfter
<getConflictingProtoDef
, getDefinition
,
367 CheckImportNameConflict
>();
370 // Used for function templates and function template specializations.
371 void TypedTest_ImportDifferentDefAfterDef() {
372 TypedTest_ImportAfter
<TypeParam::getDef0
, TypeParam::getDef1
,
373 CheckImportedAsNew
>();
375 void TypedTest_DontImportSameDefAfterDef() {
376 TypedTest_ImportAfter
<TypeParam::getDef0
, TypeParam::getDef0
,
377 CheckImportFoundExisting
>();
381 // ==============================
382 // Define the parametrized tests.
383 // ==============================
385 #define ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE( \
386 TypeParam, ODRHandlingParam, NamePrefix, TestCase) \
387 using TypeParam##ODRHandlingParam = \
388 ODRViolation<TypeParam, ASTImporter::ODRHandlingType::ODRHandlingParam>; \
389 TEST_P(TypeParam##ODRHandlingParam, NamePrefix##TestCase) { \
390 TypedTest_##TestCase(); \
395 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
397 ImportConflictingDefAfterDef
)
398 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
400 ImportConflictingDefAfterDef
)
401 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
402 TypedefAlias
, Liberal
, ,
403 ImportConflictingDefAfterDef
)
404 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
406 ImportConflictingDefAfterDef
)
407 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
408 EnumClass
, Liberal
, ,
409 ImportConflictingDefAfterDef
)
410 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
411 EnumConstant
, Liberal
, ,
412 ImportConflictingDefAfterDef
)
413 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
415 ImportConflictingDefAfterDef
)
416 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
418 ImportConflictingDefAfterDef
)
419 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
420 ClassTemplate
, Liberal
, ,
421 ImportConflictingDefAfterDef
)
422 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
423 VarTemplate
, Liberal
, ,
424 ImportConflictingDefAfterDef
)
425 // Class and variable template specializations/instantiatons are always
426 // imported conservatively, because the AST holds the specializations in a set,
427 // and the key within the set is a hash calculated from the arguments of the
429 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
430 ClassTemplateSpec
, Liberal
, ,
431 DontImportConflictingDefAfterDef
) // Don't import !!!
432 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
433 VarTemplateSpec
, Liberal
, ,
434 DontImportConflictingDefAfterDef
) // Don't import !!!
436 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
437 Function
, Conservative
, ,
438 DontImportConflictingDefAfterDef
)
439 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
440 Typedef
, Conservative
, ,
441 DontImportConflictingDefAfterDef
)
442 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
443 TypedefAlias
, Conservative
, ,
444 DontImportConflictingDefAfterDef
)
445 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
446 Enum
, Conservative
, ,
447 DontImportConflictingDefAfterDef
)
448 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
449 EnumClass
, Conservative
, ,
450 DontImportConflictingDefAfterDef
)
451 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
452 EnumConstant
, Conservative
, ,
453 DontImportConflictingDefAfterDef
)
454 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
455 Class
, Conservative
, ,
456 DontImportConflictingDefAfterDef
)
457 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
458 Variable
, Conservative
, ,
459 DontImportConflictingDefAfterDef
)
460 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
461 ClassTemplate
, Conservative
, ,
462 DontImportConflictingDefAfterDef
)
463 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
464 VarTemplate
, Conservative
, ,
465 DontImportConflictingDefAfterDef
)
466 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
467 ClassTemplateSpec
, Conservative
, ,
468 DontImportConflictingDefAfterDef
)
469 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
470 VarTemplateSpec
, Conservative
, ,
471 DontImportConflictingDefAfterDef
)
473 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
475 ImportConflictingProtoAfterProto
)
476 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
478 ImportConflictingProtoAfterProto
)
479 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
480 ClassTemplate
, Liberal
, ,
481 ImportConflictingProtoAfterProto
)
483 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
484 Function
, Conservative
, ,
485 DontImportConflictingProtoAfterProto
)
486 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
487 Variable
, Conservative
, ,
488 DontImportConflictingProtoAfterProto
)
489 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
490 ClassTemplate
, Conservative
, ,
491 DontImportConflictingProtoAfterProto
)
493 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
495 ImportConflictingProtoAfterDef
)
496 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
497 ClassTemplate
, Liberal
, ,
498 ImportConflictingProtoAfterDef
)
500 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
501 Variable
, Conservative
, ,
502 DontImportConflictingProtoAfterDef
)
503 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
504 ClassTemplate
, Conservative
, ,
505 DontImportConflictingProtoAfterDef
)
507 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
509 ImportConflictingDefAfterProto
)
510 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
512 ImportConflictingDefAfterProto
)
513 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
514 ClassTemplate
, Liberal
, ,
515 ImportConflictingDefAfterProto
)
517 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
518 Function
, Conservative
, ,
519 DontImportConflictingDefAfterProto
)
520 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
521 Variable
, Conservative
, ,
522 DontImportConflictingDefAfterProto
)
523 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
524 ClassTemplate
, Conservative
, ,
525 DontImportConflictingDefAfterProto
)
527 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
528 ClassTemplate
, Liberal
, ,
529 ImportConflictingProtoDefAfterProto
)
531 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
532 ClassTemplate
, Conservative
, ,
533 DontImportConflictingProtoDefAfterProto
)
535 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
536 ClassTemplate
, Liberal
, ,
537 ImportConflictingProtoAfterProtoDef
)
539 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
540 ClassTemplate
, Conservative
, ,
541 DontImportConflictingProtoAfterProtoDef
)
543 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
544 ClassTemplate
, Liberal
, ,
545 ImportConflictingProtoDefAfterDef
)
547 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
548 ClassTemplate
, Conservative
, ,
549 DontImportConflictingProtoDefAfterDef
)
551 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
552 ClassTemplate
, Liberal
, ,
553 ImportConflictingDefAfterProtoDef
)
555 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
556 ClassTemplate
, Conservative
, ,
557 DontImportConflictingDefAfterProtoDef
)
559 // FunctionTemplate decls overload with each other. Thus, they are imported
560 // always as a new node, independently from any ODRHandling strategy.
562 // Function template specializations are "full" specializations. Structural
563 // equivalency does not check the body of functions, so we cannot create
564 // conflicting function template specializations. Thus, ODR handling strategies
565 // has nothing to do with function template specializations. Fully specialized
566 // function templates are imported as new nodes if their template arguments are
568 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
569 FunctionTemplate
, Liberal
, ,
570 ImportDifferentDefAfterDef
)
571 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
572 FunctionTemplateSpec
, Liberal
, ,
573 ImportDifferentDefAfterDef
)
574 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
575 FunctionTemplate
, Conservative
, ,
576 ImportDifferentDefAfterDef
)
577 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
578 FunctionTemplateSpec
, Conservative
, ,
579 ImportDifferentDefAfterDef
)
580 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
581 FunctionTemplate
, Liberal
, ,
582 DontImportSameDefAfterDef
)
583 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
584 FunctionTemplateSpec
, Liberal
, ,
585 DontImportSameDefAfterDef
)
586 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
587 FunctionTemplate
, Conservative
, ,
588 DontImportSameDefAfterDef
)
589 ASTIMPORTER_ODR_INSTANTIATE_TYPED_TEST_SUITE(
590 FunctionTemplateSpec
, Conservative
, ,
591 DontImportSameDefAfterDef
)
593 // ======================
594 // Instantiate the tests.
595 // ======================
597 // FIXME: These fail on Windows.
599 INSTANTIATE_TEST_SUITE_P(
600 ODRViolationTests
, FunctionConservative
,
601 DefaultTestValuesForRunOptions
);
603 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FunctionConservative
);
605 INSTANTIATE_TEST_SUITE_P(
606 ODRViolationTests
, TypedefConservative
,
607 DefaultTestValuesForRunOptions
);
608 INSTANTIATE_TEST_SUITE_P(
609 ODRViolationTests
, TypedefAliasConservative
,
610 DefaultTestValuesForRunOptions
);
611 INSTANTIATE_TEST_SUITE_P(
612 ODRViolationTests
, EnumConservative
,
613 DefaultTestValuesForRunOptions
);
614 INSTANTIATE_TEST_SUITE_P(
615 ODRViolationTests
, EnumClassConservative
,
616 DefaultTestValuesForRunOptions
);
617 INSTANTIATE_TEST_SUITE_P(
618 ODRViolationTests
, EnumConstantConservative
,
619 DefaultTestValuesForRunOptions
);
620 INSTANTIATE_TEST_SUITE_P(
621 ODRViolationTests
, ClassConservative
,
622 DefaultTestValuesForRunOptions
);
623 INSTANTIATE_TEST_SUITE_P(
624 ODRViolationTests
, VariableConservative
,
625 DefaultTestValuesForRunOptions
);
626 INSTANTIATE_TEST_SUITE_P(
627 ODRViolationTests
, ClassTemplateConservative
,
628 DefaultTestValuesForRunOptions
);
629 INSTANTIATE_TEST_SUITE_P(
630 ODRViolationTests
, FunctionTemplateConservative
,
631 DefaultTestValuesForRunOptions
);
632 // FIXME: Make VarTemplate tests work.
633 //INSTANTIATE_TEST_SUITE_P(
634 //ODRViolationTests, VarTemplateConservative,
635 //DefaultTestValuesForRunOptions);
636 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateConservative
);
638 INSTANTIATE_TEST_SUITE_P(
639 ODRViolationTests
, FunctionTemplateSpecConservative
,
640 DefaultTestValuesForRunOptions
);
641 INSTANTIATE_TEST_SUITE_P(
642 ODRViolationTests
, ClassTemplateSpecConservative
,
643 DefaultTestValuesForRunOptions
);
644 // FIXME: Make VarTemplateSpec tests work.
645 //INSTANTIATE_TEST_SUITE_P(
646 //ODRViolationTests, VarTemplateSpecConservative,
647 //DefaultTestValuesForRunOptions);
648 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateSpecConservative
);
650 // FIXME: These fail on Windows.
652 INSTANTIATE_TEST_SUITE_P(
653 ODRViolationTests
, FunctionLiberal
,
654 DefaultTestValuesForRunOptions
);
656 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(FunctionLiberal
);
658 INSTANTIATE_TEST_SUITE_P(
659 ODRViolationTests
, TypedefLiberal
,
660 DefaultTestValuesForRunOptions
);
661 INSTANTIATE_TEST_SUITE_P(
662 ODRViolationTests
, TypedefAliasLiberal
,
663 DefaultTestValuesForRunOptions
);
664 INSTANTIATE_TEST_SUITE_P(
665 ODRViolationTests
, EnumLiberal
,
666 DefaultTestValuesForRunOptions
);
667 INSTANTIATE_TEST_SUITE_P(
668 ODRViolationTests
, EnumClassLiberal
,
669 DefaultTestValuesForRunOptions
);
670 INSTANTIATE_TEST_SUITE_P(
671 ODRViolationTests
, EnumConstantLiberal
,
672 DefaultTestValuesForRunOptions
);
673 INSTANTIATE_TEST_SUITE_P(
674 ODRViolationTests
, ClassLiberal
,
675 DefaultTestValuesForRunOptions
);
676 INSTANTIATE_TEST_SUITE_P(
677 ODRViolationTests
, VariableLiberal
,
678 DefaultTestValuesForRunOptions
);
679 INSTANTIATE_TEST_SUITE_P(
680 ODRViolationTests
, ClassTemplateLiberal
,
681 DefaultTestValuesForRunOptions
);
682 INSTANTIATE_TEST_SUITE_P(
683 ODRViolationTests
, FunctionTemplateLiberal
,
684 DefaultTestValuesForRunOptions
);
685 // FIXME: Make VarTemplate tests work.
686 // INSTANTIATE_TEST_SUITE_P(
687 // ODRViolationTests, VarTemplateLiberal,
688 // DefaultTestValuesForRunOptions);
689 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateLiberal
);
691 INSTANTIATE_TEST_SUITE_P(
692 ODRViolationTests
, ClassTemplateSpecLiberal
,
693 DefaultTestValuesForRunOptions
);
694 INSTANTIATE_TEST_SUITE_P(
695 ODRViolationTests
, FunctionTemplateSpecLiberal
,
696 DefaultTestValuesForRunOptions
);
697 // FIXME: Make VarTemplateSpec tests work.
698 //INSTANTIATE_TEST_SUITE_P(
699 //ODRViolationTests, VarTemplateSpecLiberal,
700 //DefaultTestValuesForRunOptions );
701 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VarTemplateSpecLiberal
);
705 } // end namespace ast_matchers
706 } // end namespace clang