Index: unittests/AST/ASTImporterTest.cpp =================================================================== --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -58,23 +58,31 @@ // Common base for the different families of ASTImporter tests that are // parameterized on the compiler options which may result a different AST. E.g. // -fms-compatibility or -fdelayed-template-parsing. -struct ParameterizedTestsFixture : ::testing::TestWithParam { +class CompilerOptionSpecificTest : public ::testing::Test { +protected: + // Return the extra arguments appended to runtime options at compilation. + virtual ArgVector getExtraArgs() const { return ArgVector(); } // Returns the argument vector used for a specific language option, this set // can be tweaked by the test parameters. ArgVector getArgVectorForLanguage(Language Lang) const { ArgVector Args = getBasicRunOptionsForLanguage(Lang); - ArgVector ExtraArgs = GetParam(); + ArgVector ExtraArgs = getExtraArgs(); for (const auto &Arg : ExtraArgs) { Args.push_back(Arg); } return Args; } - }; +auto DefaultTestValuesForRunOptions = ::testing::Values( + ArgVector(), ArgVector{"-fdelayed-template-parsing"}, + ArgVector{"-fms-compatibility"}, + ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"}); + // Base class for those tests which use the family of `testImport` functions. -class TestImportBase : public ParameterizedTestsFixture { +class TestImportBase : public CompilerOptionSpecificTest, + public ::testing::WithParamInterface { template NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer, @@ -159,6 +167,9 @@ VerificationMatcher); } +protected: + ArgVector getExtraArgs() const override { return GetParam(); } + public: /// Test how AST node named "declToImport" located in the translation unit @@ -284,7 +295,7 @@ // This class provides generic methods to write tests which can check internal // attributes of AST nodes like getPreviousDecl(), isVirtual(), etc. Also, // this fixture makes it possible to import from several "From" contexts. -class ASTImporterTestBase : public ParameterizedTestsFixture { +class ASTImporterTestBase : public CompilerOptionSpecificTest { const char *const InputFileName = "input.cc"; const char *const OutputFileName = "output.cc"; @@ -473,11 +484,18 @@ } }; +class ASTImporterOptionSpecificTestBase + : public ASTImporterTestBase, + public ::testing::WithParamInterface { +protected: + ArgVector getExtraArgs() const override { return GetParam(); } +}; + struct ImportExpr : TestImportBase {}; struct ImportType : TestImportBase {}; struct ImportDecl : TestImportBase {}; -struct CanonicalRedeclChain : ASTImporterTestBase {}; +struct CanonicalRedeclChain : ASTImporterOptionSpecificTestBase {}; TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) { Decl *FromTU = getTuDecl("void f();", Lang_CXX); @@ -1000,7 +1018,7 @@ has(declStmt(hasSingleDecl(varDecl(hasName("d"))))))))); } -TEST_P(ASTImporterTestBase, ImportRecordTypeInFunc) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) { Decl *FromTU = getTuDecl("int declToImport() { " " struct data_t {int a;int b;};" " struct data_t d;" @@ -1015,7 +1033,7 @@ EXPECT_FALSE(ToType.isNull()); } -TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParams) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordDeclInFuncParams) { // This construct is not supported by ASTImporter. Decl *FromTU = getTuDecl( "int declToImport(struct data_t{int a;int b;} ***d){ return 0; }", @@ -1027,7 +1045,7 @@ EXPECT_EQ(To, nullptr); } -TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncFromMacro) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordDeclInFuncFromMacro) { Decl *FromTU = getTuDecl( "#define NONAME_SIZEOF(type) sizeof(struct{type *dummy;}) \n" "int declToImport(){ return NONAME_SIZEOF(int); }", @@ -1042,7 +1060,8 @@ hasDescendant(unaryExprOrTypeTraitExpr())))); } -TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParamsFromMacro) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportRecordDeclInFuncParamsFromMacro) { // This construct is not supported by ASTImporter. Decl *FromTU = getTuDecl( "#define PAIR_STRUCT(type) struct data_t{type a;type b;} \n" @@ -1194,7 +1213,8 @@ has(fieldDecl(hasType(dependentSizedArrayType()))))))); } -TEST_P(ASTImporterTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportOfTemplatedDeclOfClassTemplateDecl) { Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX); auto From = FirstDeclMatcher().match(FromTU, classTemplateDecl()); @@ -1207,7 +1227,8 @@ EXPECT_EQ(ToTemplated1, ToTemplated); } -TEST_P(ASTImporterTestBase, ImportOfTemplatedDeclOfFunctionTemplateDecl) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportOfTemplatedDeclOfFunctionTemplateDecl) { Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX); auto From = FirstDeclMatcher().match( FromTU, functionTemplateDecl()); @@ -1220,7 +1241,7 @@ EXPECT_EQ(ToTemplated1, ToTemplated); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclShouldImportTheClassTemplateDecl) { Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX); auto FromFT = @@ -1236,7 +1257,7 @@ EXPECT_TRUE(ToFT); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclShouldImportTheFunctionTemplateDecl) { Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX); auto FromFT = FirstDeclMatcher().match( @@ -1252,7 +1273,7 @@ EXPECT_TRUE(ToFT); } -TEST_P(ASTImporterTestBase, ImportCorrectTemplatedDecl) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportCorrectTemplatedDecl) { auto Code = R"( namespace x { @@ -1283,7 +1304,8 @@ ASSERT_EQ(ToTemplated1, ToTemplated); } -TEST_P(ASTImporterTestBase, ImportFunctionWithBackReferringParameter) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportFunctionWithBackReferringParameter) { Decl *From, *To; std::tie(From, To) = getImportedDecl( R"( @@ -1310,7 +1332,7 @@ EXPECT_TRUE(Verifier.match(To, Matcher)); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, TUshouldNotContainTemplatedDeclOfFunctionTemplates) { Decl *From, *To; std::tie(From, To) = @@ -1336,7 +1358,8 @@ EXPECT_TRUE(Check(To)); } -TEST_P(ASTImporterTestBase, TUshouldNotContainTemplatedDeclOfClassTemplates) { +TEST_P(ASTImporterOptionSpecificTestBase, + TUshouldNotContainTemplatedDeclOfClassTemplates) { Decl *From, *To; std::tie(From, To) = getImportedDecl("template struct declToImport { T t; };" @@ -1361,7 +1384,8 @@ EXPECT_TRUE(Check(To)); } -TEST_P(ASTImporterTestBase, TUshouldNotContainTemplatedDeclOfTypeAlias) { +TEST_P(ASTImporterOptionSpecificTestBase, + TUshouldNotContainTemplatedDeclOfTypeAlias) { Decl *From, *To; std::tie(From, To) = getImportedDecl( @@ -1388,9 +1412,8 @@ EXPECT_TRUE(Check(To)); } -TEST_P( - ASTImporterTestBase, - TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) { +TEST_P(ASTImporterOptionSpecificTestBase, + TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) { Decl *From, *To; std::tie(From, To) = getImportedDecl( @@ -1431,7 +1454,7 @@ return Index == Order.size(); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, TUshouldContainClassTemplateSpecializationOfExplicitInstantiation) { Decl *From, *To; std::tie(From, To) = getImportedDecl( @@ -1458,7 +1481,8 @@ EXPECT_TRUE(MatchVerifier{}.match(To, Pattern)); } -TEST_P(ASTImporterTestBase, CXXRecordDeclFieldsShouldBeInCorrectOrder) { +TEST_P(ASTImporterOptionSpecificTestBase, + CXXRecordDeclFieldsShouldBeInCorrectOrder) { Decl *From, *To; std::tie(From, To) = getImportedDecl( @@ -1470,7 +1494,7 @@ EXPECT_TRUE(Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b"})))); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) { Decl *From, *To; std::tie(From, To) = getImportedDecl( @@ -1492,7 +1516,7 @@ Verifier.match(To, cxxRecordDecl(hasFieldOrder({"a", "b", "c"})))); } -TEST_P(ASTImporterTestBase, ShouldImportImplicitCXXRecordDecl) { +TEST_P(ASTImporterOptionSpecificTestBase, ShouldImportImplicitCXXRecordDecl) { Decl *From, *To; std::tie(From, To) = getImportedDecl( R"( @@ -1508,7 +1532,8 @@ EXPECT_TRUE(Verifier.match(To, Matcher)); } -TEST_P(ASTImporterTestBase, ShouldImportImplicitCXXRecordDeclOfClassTemplate) { +TEST_P(ASTImporterOptionSpecificTestBase, + ShouldImportImplicitCXXRecordDeclOfClassTemplate) { Decl *From, *To; std::tie(From, To) = getImportedDecl( R"( @@ -1525,9 +1550,8 @@ EXPECT_TRUE(Verifier.match(To, Matcher)); } -TEST_P( - ASTImporterTestBase, - ShouldImportImplicitCXXRecordDeclOfClassTemplateSpecializationDecl) { +TEST_P(ASTImporterOptionSpecificTestBase, + ShouldImportImplicitCXXRecordDeclOfClassTemplateSpecializationDecl) { Decl *From, *To; std::tie(From, To) = getImportedDecl( R"( @@ -1547,7 +1571,7 @@ MatchVerifier{}.match(To->getTranslationUnitDecl(), Pattern)); } -TEST_P(ASTImporterTestBase, IDNSOrdinary) { +TEST_P(ASTImporterOptionSpecificTestBase, IDNSOrdinary) { Decl *From, *To; std::tie(From, To) = getImportedDecl("void declToImport() {}", Lang_CXX, "", Lang_CXX); @@ -1559,7 +1583,7 @@ EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace()); } -TEST_P(ASTImporterTestBase, IDNSOfNonmemberOperator) { +TEST_P(ASTImporterOptionSpecificTestBase, IDNSOfNonmemberOperator) { Decl *FromTU = getTuDecl( R"( struct X {}; @@ -1571,7 +1595,7 @@ EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace()); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ShouldImportMembersOfClassTemplateSpecializationDecl) { Decl *From, *To; std::tie(From, To) = getImportedDecl( @@ -1591,7 +1615,8 @@ MatchVerifier{}.match(To->getTranslationUnitDecl(), Pattern)); } -TEST_P(ASTImporterTestBase, ImportDefinitionOfClassTemplateAfterFwdDecl) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportDefinitionOfClassTemplateAfterFwdDecl) { { Decl *FromTU = getTuDecl( R"( @@ -1624,7 +1649,7 @@ } } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ImportDefinitionOfClassTemplateIfThereIsAnExistingFwdDeclAndDefinition) { Decl *ToTU = getToTuDecl( R"( @@ -1664,7 +1689,7 @@ .match(ToTU, classTemplateDecl())); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ImportDefinitionOfClassIfThereIsAnExistingFwdDeclAndDefinition) { Decl *ToTU = getToTuDecl( R"( @@ -1707,7 +1732,7 @@ CompareSourceLocs(FullSourceLoc{ Range1.getEnd(), SM1 }, FullSourceLoc{ Range2.getEnd(), SM2 }); } -TEST_P(ASTImporterTestBase, ImportSourceLocs) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportSourceLocs) { Decl *FromTU = getTuDecl( R"( #define MFOO(arg) arg = arg + 1 @@ -1737,7 +1762,7 @@ FromSM); } -TEST_P(ASTImporterTestBase, ImportNestedMacro) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportNestedMacro) { Decl *FromTU = getTuDecl( R"( #define FUNC_INT void declToImport @@ -1755,9 +1780,8 @@ } TEST_P( - ASTImporterTestBase, - ImportDefinitionOfClassTemplateSpecIfThereIsAnExistingFwdDeclAndDefinition) -{ + ASTImporterOptionSpecificTestBase, + ImportDefinitionOfClassTemplateSpecIfThereIsAnExistingFwdDeclAndDefinition) { Decl *ToTU = getToTuDecl( R"( template @@ -1799,7 +1823,7 @@ .match(ToTU, classTemplateSpecializationDecl())); } -TEST_P(ASTImporterTestBase, ObjectsWithUnnamedStructType) { +TEST_P(ASTImporterOptionSpecificTestBase, ObjectsWithUnnamedStructType) { Decl *FromTU = getTuDecl( R"( struct { int a; int b; } object0 = { 2, 3 }; @@ -1823,7 +1847,7 @@ EXPECT_NE(To0->getCanonicalDecl(), To1->getCanonicalDecl()); } -TEST_P(ASTImporterTestBase, AnonymousRecords) { +TEST_P(ASTImporterOptionSpecificTestBase, AnonymousRecords) { auto *Code = R"( struct X { @@ -1849,7 +1873,7 @@ DeclCounter().match(ToTU, recordDecl(hasName("X")))); } -TEST_P(ASTImporterTestBase, AnonymousRecordsReversed) { +TEST_P(ASTImporterOptionSpecificTestBase, AnonymousRecordsReversed) { Decl *FromTU0 = getTuDecl( R"( struct X { @@ -1882,7 +1906,7 @@ DeclCounter().match(ToTU, recordDecl(hasName("X")))); } -TEST_P(ASTImporterTestBase, ImportDoesUpdateUsedFlag) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportDoesUpdateUsedFlag) { auto Pattern = varDecl(hasName("x")); VarDecl *Imported1; { @@ -1908,7 +1932,7 @@ EXPECT_TRUE(Imported2->isUsed(false)); } -TEST_P(ASTImporterTestBase, ImportDoesUpdateUsedFlag2) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportDoesUpdateUsedFlag2) { auto Pattern = varDecl(hasName("x")); VarDecl *ExistingD; { @@ -1926,7 +1950,7 @@ EXPECT_TRUE(ExistingD->isUsed(false)); } -TEST_P(ASTImporterTestBase, ImportDoesUpdateUsedFlag3) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportDoesUpdateUsedFlag3) { auto Pattern = varDecl(hasName("a")); VarDecl *ExistingD; { @@ -1957,7 +1981,7 @@ EXPECT_TRUE(ExistingD->isUsed(false)); } -TEST_P(ASTImporterTestBase, ReimportWithUsedFlag) { +TEST_P(ASTImporterOptionSpecificTestBase, ReimportWithUsedFlag) { auto Pattern = varDecl(hasName("x")); Decl *FromTU = getTuDecl("int x;", Lang_CXX, "input0.cc"); @@ -1974,7 +1998,7 @@ EXPECT_TRUE(Imported2->isUsed(false)); } -struct ImportFunctions : ASTImporterTestBase {}; +struct ImportFunctions : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportFunctions, DefinitionShouldBeImportedAsDefintionWhenThereIsAPrototype) { @@ -2885,7 +2909,7 @@ compoundStmt(has(callExpr(has(unresolvedMemberExpr()))))))))); } -class ImportImplicitMethods : public ASTImporterTestBase { +class ImportImplicitMethods : public ASTImporterOptionSpecificTestBase { public: static constexpr auto DefaultCode = R"( struct A { int x; }; @@ -2997,7 +3021,7 @@ testNoImportOf(cxxMethodDecl(hasName("f")), Code); } -TEST_P(ASTImporterTestBase, ImportOfEquivalentRecord) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfEquivalentRecord) { Decl *ToR1; { Decl *FromTU = getTuDecl( @@ -3021,7 +3045,7 @@ EXPECT_EQ(ToR1, ToR2); } -TEST_P(ASTImporterTestBase, ImportOfNonEquivalentRecord) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentRecord) { Decl *ToR1; { Decl *FromTU = getTuDecl( @@ -3041,7 +3065,7 @@ EXPECT_NE(ToR1, ToR2); } -TEST_P(ASTImporterTestBase, ImportOfEquivalentField) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfEquivalentField) { Decl *ToF1; { Decl *FromTU = getTuDecl( @@ -3061,7 +3085,7 @@ EXPECT_EQ(ToF1, ToF2); } -TEST_P(ASTImporterTestBase, ImportOfNonEquivalentField) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentField) { Decl *ToF1; { Decl *FromTU = getTuDecl( @@ -3081,7 +3105,7 @@ EXPECT_NE(ToF1, ToF2); } -TEST_P(ASTImporterTestBase, ImportOfEquivalentMethod) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfEquivalentMethod) { Decl *ToM1; { Decl *FromTU = getTuDecl( @@ -3101,7 +3125,7 @@ EXPECT_EQ(ToM1, ToM2); } -TEST_P(ASTImporterTestBase, ImportOfNonEquivalentMethod) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentMethod) { Decl *ToM1; { Decl *FromTU = getTuDecl( @@ -3123,7 +3147,8 @@ EXPECT_NE(ToM1, ToM2); } -TEST_P(ASTImporterTestBase, ImportUnnamedStructsWithRecursingField) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportUnnamedStructsWithRecursingField) { Decl *FromTU = getTuDecl( R"( struct A { @@ -3155,7 +3180,7 @@ R1, recordDecl(has(fieldDecl(hasName("next")))))); } -TEST_P(ASTImporterTestBase, ImportUnnamedFieldsInCorrectOrder) { +TEST_P(ASTImporterOptionSpecificTestBase, ImportUnnamedFieldsInCorrectOrder) { Decl *FromTU = getTuDecl( R"( void f(int X, int Y, bool Z) { @@ -3190,7 +3215,8 @@ EXPECT_EQ(FromIndex, 3u); } -TEST_P(ASTImporterTestBase, MergeFieldDeclsOfClassTemplateSpecialization) { +TEST_P(ASTImporterOptionSpecificTestBase, + MergeFieldDeclsOfClassTemplateSpecialization) { std::string ClassTemplate = R"( template @@ -3235,7 +3261,8 @@ EXPECT_TRUE(ToField->getInClassInitializer()); } -TEST_P(ASTImporterTestBase, MergeFunctionOfClassTemplateSpecialization) { +TEST_P(ASTImporterOptionSpecificTestBase, + MergeFunctionOfClassTemplateSpecialization) { std::string ClassTemplate = R"( template @@ -3276,7 +3303,7 @@ EXPECT_TRUE(ToFun->hasBody()); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ODRViolationOfClassTemplateSpecializationsShouldBeReported) { std::string ClassTemplate = R"( @@ -3323,7 +3350,8 @@ ToTU, classTemplateSpecializationDecl())); } -TEST_P(ASTImporterTestBase, MergeCtorOfClassTemplateSpecialization) { +TEST_P(ASTImporterOptionSpecificTestBase, + MergeCtorOfClassTemplateSpecialization) { std::string ClassTemplate = R"( template @@ -3364,7 +3392,7 @@ EXPECT_TRUE(ToCtor->hasBody()); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ClassTemplatePartialSpecializationsShouldNotBeDuplicated) { auto Code = R"( @@ -3391,7 +3419,8 @@ ToTU, classTemplatePartialSpecializationDecl())); } -TEST_P(ASTImporterTestBase, ClassTemplateSpecializationsShouldNotBeDuplicated) { +TEST_P(ASTImporterOptionSpecificTestBase, + ClassTemplateSpecializationsShouldNotBeDuplicated) { auto Code = R"( // primary template @@ -3415,7 +3444,8 @@ ToTU, classTemplateSpecializationDecl())); } -TEST_P(ASTImporterTestBase, ClassTemplateFullAndPartialSpecsShouldNotBeMixed) { +TEST_P(ASTImporterOptionSpecificTestBase, + ClassTemplateFullAndPartialSpecsShouldNotBeMixed) { std::string PrimaryTemplate = R"( template @@ -3447,7 +3477,8 @@ unless(classTemplatePartialSpecializationDecl())))); } -TEST_P(ASTImporterTestBase, InitListExprValueKindShouldBeImported) { +TEST_P(ASTImporterOptionSpecificTestBase, + InitListExprValueKindShouldBeImported) { Decl *TU = getTuDecl( R"( const int &init(); @@ -3466,7 +3497,7 @@ EXPECT_TRUE(ToInitExpr->isGLValue()); } -struct ImportVariables : ASTImporterTestBase {}; +struct ImportVariables : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportVariables, ImportOfOneDeclBringsInTheWholeChain) { Decl *FromTU = getTuDecl( @@ -3554,7 +3585,7 @@ EXPECT_TRUE(ImportedD->getDefinition()); } -struct ImportClasses : ASTImporterTestBase {}; +struct ImportClasses : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportClasses, PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition) { @@ -3762,7 +3793,7 @@ EXPECT_EQ(ToDef->getPreviousDecl(), ToProto); } -struct ImportClassTemplates : ASTImporterTestBase {}; +struct ImportClassTemplates : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportClassTemplates, PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition) { @@ -3926,7 +3957,7 @@ ToProto->getTemplatedDecl()); } -struct ImportFriendClasses : ASTImporterTestBase {}; +struct ImportFriendClasses : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportFriendClasses, ImportOfFriendRecordDoesNotMergeDefinition) { Decl *FromTU = getTuDecl( @@ -4166,7 +4197,7 @@ EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl()); } -TEST_P(ASTImporterTestBase, FriendFunInClassTemplate) { +TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) { auto *Code = R"( template struct X { @@ -4184,7 +4215,7 @@ EXPECT_EQ(ImportedFoo, ToFoo); } -struct DeclContextTest : ASTImporterTestBase {}; +struct DeclContextTest : ASTImporterOptionSpecificTestBase {}; TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) { Decl *TU = getTuDecl( @@ -4247,7 +4278,8 @@ EXPECT_FALSE(DC->containsDecl(A0)); } -struct ImportFunctionTemplateSpecializations : ASTImporterTestBase {}; +struct ImportFunctionTemplateSpecializations + : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportFunctionTemplateSpecializations, TUshouldNotContainFunctionTemplateImplicitInstantiation) { @@ -4562,7 +4594,7 @@ EXPECT_EQ(To1->getPreviousDecl(), To0); } -TEST_P(ASTImporterTestBase, +TEST_P(ASTImporterOptionSpecificTestBase, ImportShouldNotReportFalseODRErrorWhenRecordIsBeingDefined) { { Decl *FromTU = getTuDecl( @@ -4601,7 +4633,8 @@ } } -TEST_P(ASTImporterTestBase, ImportingTypedefShouldImportTheCompleteType) { +TEST_P(ASTImporterOptionSpecificTestBase, + ImportingTypedefShouldImportTheCompleteType) { // We already have an incomplete underlying type in the "To" context. auto Code = R"( @@ -4633,7 +4666,7 @@ EXPECT_FALSE(ImportedD->getUnderlyingType()->isIncompleteType()); } -struct ASTImporterLookupTableTest : ASTImporterTestBase {}; +struct ASTImporterLookupTableTest : ASTImporterOptionSpecificTestBase {}; TEST_P(ASTImporterLookupTableTest, OneDecl) { auto *ToTU = getToTuDecl("int a;", Lang_CXX); @@ -5050,12 +5083,6 @@ ParameterizedTests, CanonicalRedeclChain, ::testing::Values(ArgVector()),); -auto DefaultTestValuesForRunOptions = ::testing::Values( - ArgVector(), - ArgVector{"-fdelayed-template-parsing"}, - ArgVector{"-fms-compatibility"}, - ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"}); - INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest, DefaultTestValuesForRunOptions, ); @@ -5068,7 +5095,7 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportDecl, DefaultTestValuesForRunOptions, ); -INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterTestBase, +INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterOptionSpecificTestBase, DefaultTestValuesForRunOptions, ); INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctions,