diff --git a/clang/include/clang/Testing/CommandLineArgs.h b/clang/include/clang/Testing/CommandLineArgs.h --- a/clang/include/clang/Testing/CommandLineArgs.h +++ b/clang/include/clang/Testing/CommandLineArgs.h @@ -19,13 +19,13 @@ namespace clang { enum TestLanguage { - Lang_C, Lang_C89, - Lang_CXX, + Lang_C99, + Lang_CXX03, Lang_CXX11, Lang_CXX14, Lang_CXX17, - Lang_CXX2a, + Lang_CXX20, Lang_OpenCL, Lang_OBJCXX }; diff --git a/clang/lib/Testing/CommandLineArgs.cpp b/clang/lib/Testing/CommandLineArgs.cpp --- a/clang/lib/Testing/CommandLineArgs.cpp +++ b/clang/lib/Testing/CommandLineArgs.cpp @@ -15,14 +15,14 @@ std::vector Args; // Test with basic arguments. switch (Lang) { - case Lang_C: - Args = {"-x", "c", "-std=c99"}; - break; case Lang_C89: Args = {"-x", "c", "-std=c89"}; break; - case Lang_CXX: - Args = {"-std=c++98", "-frtti"}; + case Lang_C99: + Args = {"-x", "c", "-std=c99"}; + break; + case Lang_CXX03: + Args = {"-std=c++03", "-frtti"}; break; case Lang_CXX11: Args = {"-std=c++11", "-frtti"}; @@ -33,8 +33,8 @@ case Lang_CXX17: Args = {"-std=c++17", "-frtti"}; break; - case Lang_CXX2a: - Args = {"-std=c++2a", "-frtti"}; + case Lang_CXX20: + Args = {"-std=c++20", "-frtti"}; break; case Lang_OBJCXX: Args = {"-x", "objective-c++", "-frtti"}; diff --git a/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp b/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp --- a/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp +++ b/clang/unittests/AST/ASTImporterGenericRedeclTest.cpp @@ -180,11 +180,11 @@ void TypedTest_PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition() { - Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX); + Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX03); auto *FromD = FirstDeclMatcher().match(FromTU, getPattern()); ASSERT_FALSE(FromD->isThisDeclarationADefinition()); - Decl *ImportedD = Import(FromD, Lang_CXX); + Decl *ImportedD = Import(FromD, Lang_CXX03); Decl *ToTU = ImportedD->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, getPattern()), 1u); @@ -197,11 +197,11 @@ } void TypedTest_DefinitionShouldBeImportedAsADefinition() { - Decl *FromTU = getTuDecl(getDefinition(), Lang_CXX); + Decl *FromTU = getTuDecl(getDefinition(), Lang_CXX03); auto *FromD = FirstDeclMatcher().match(FromTU, getPattern()); ASSERT_TRUE(FromD->isThisDeclarationADefinition()); - Decl *ImportedD = Import(FromD, Lang_CXX); + Decl *ImportedD = Import(FromD, Lang_CXX03); Decl *ToTU = ImportedD->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, getPattern()), 1u); @@ -213,14 +213,14 @@ } void TypedTest_ImportPrototypeAfterImportedPrototype() { - Decl *FromTU = getTuDecl(getPrototype() + getPrototype(), Lang_CXX); + Decl *FromTU = getTuDecl(getPrototype() + getPrototype(), Lang_CXX03); auto *From0 = FirstDeclMatcher().match(FromTU, getPattern()); auto *From1 = LastDeclMatcher().match(FromTU, getPattern()); ASSERT_FALSE(From0->isThisDeclarationADefinition()); ASSERT_FALSE(From1->isThisDeclarationADefinition()); - Decl *Imported0 = Import(From0, Lang_CXX); - Decl *Imported1 = Import(From1, Lang_CXX); + Decl *Imported0 = Import(From0, Lang_CXX03); + Decl *Imported1 = Import(From1, Lang_CXX03); Decl *ToTU = Imported0->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, getPattern()), 2u); @@ -235,14 +235,14 @@ } void TypedTest_ImportDefinitionAfterImportedPrototype() { - Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX); + Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX03); auto *FromProto = FirstDeclMatcher().match(FromTU, getPattern()); auto *FromDef = LastDeclMatcher().match(FromTU, getPattern()); ASSERT_FALSE(FromProto->isThisDeclarationADefinition()); ASSERT_TRUE(FromDef->isThisDeclarationADefinition()); - Decl *ImportedProto = Import(FromProto, Lang_CXX); - Decl *ImportedDef = Import(FromDef, Lang_CXX); + Decl *ImportedProto = Import(FromProto, Lang_CXX03); + Decl *ImportedDef = Import(FromDef, Lang_CXX03); Decl *ToTU = ImportedProto->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, getPattern()), 2u); @@ -257,14 +257,14 @@ } void TypedTest_ImportPrototypeAfterImportedDefinition() { - Decl *FromTU = getTuDecl(getDefinition() + getPrototype(), Lang_CXX); + Decl *FromTU = getTuDecl(getDefinition() + getPrototype(), Lang_CXX03); auto *FromDef = FirstDeclMatcher().match(FromTU, getPattern()); auto *FromProto = LastDeclMatcher().match(FromTU, getPattern()); ASSERT_TRUE(FromDef->isThisDeclarationADefinition()); ASSERT_FALSE(FromProto->isThisDeclarationADefinition()); - Decl *ImportedDef = Import(FromDef, Lang_CXX); - Decl *ImportedProto = Import(FromProto, Lang_CXX); + Decl *ImportedDef = Import(FromDef, Lang_CXX03); + Decl *ImportedProto = Import(FromProto, Lang_CXX03); Decl *ToTU = ImportedDef->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, getPattern()), 2u); @@ -279,15 +279,15 @@ } void TypedTest_ImportPrototypes() { - Decl *FromTU0 = getTuDecl(getPrototype(), Lang_CXX, "input0.cc"); - Decl *FromTU1 = getTuDecl(getPrototype(), Lang_CXX, "input1.cc"); + Decl *FromTU0 = getTuDecl(getPrototype(), Lang_CXX03, "input0.cc"); + Decl *FromTU1 = getTuDecl(getPrototype(), Lang_CXX03, "input1.cc"); auto *From0 = FirstDeclMatcher().match(FromTU0, getPattern()); auto *From1 = FirstDeclMatcher().match(FromTU1, getPattern()); ASSERT_FALSE(From0->isThisDeclarationADefinition()); ASSERT_FALSE(From1->isThisDeclarationADefinition()); - Decl *Imported0 = Import(From0, Lang_CXX); - Decl *Imported1 = Import(From1, Lang_CXX); + Decl *Imported0 = Import(From0, Lang_CXX03); + Decl *Imported1 = Import(From1, Lang_CXX03); Decl *ToTU = Imported0->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, getPattern()), 2u); @@ -302,15 +302,15 @@ } void TypedTest_ImportDefinitions() { - Decl *FromTU0 = getTuDecl(getDefinition(), Lang_CXX, "input0.cc"); - Decl *FromTU1 = getTuDecl(getDefinition(), Lang_CXX, "input1.cc"); + Decl *FromTU0 = getTuDecl(getDefinition(), Lang_CXX03, "input0.cc"); + Decl *FromTU1 = getTuDecl(getDefinition(), Lang_CXX03, "input1.cc"); auto *From0 = FirstDeclMatcher().match(FromTU0, getPattern()); auto *From1 = FirstDeclMatcher().match(FromTU1, getPattern()); ASSERT_TRUE(From0->isThisDeclarationADefinition()); ASSERT_TRUE(From1->isThisDeclarationADefinition()); - Decl *Imported0 = Import(From0, Lang_CXX); - Decl *Imported1 = Import(From1, Lang_CXX); + Decl *Imported0 = Import(From0, Lang_CXX03); + Decl *Imported1 = Import(From1, Lang_CXX03); Decl *ToTU = Imported0->getTranslationUnitDecl(); EXPECT_EQ(Imported0, Imported1); @@ -324,16 +324,16 @@ } void TypedTest_ImportDefinitionThenPrototype() { - Decl *FromTUDef = getTuDecl(getDefinition(), Lang_CXX, "input0.cc"); - Decl *FromTUProto = getTuDecl(getPrototype(), Lang_CXX, "input1.cc"); + Decl *FromTUDef = getTuDecl(getDefinition(), Lang_CXX03, "input0.cc"); + Decl *FromTUProto = getTuDecl(getPrototype(), Lang_CXX03, "input1.cc"); auto *FromDef = FirstDeclMatcher().match(FromTUDef, getPattern()); auto *FromProto = FirstDeclMatcher().match(FromTUProto, getPattern()); ASSERT_TRUE(FromDef->isThisDeclarationADefinition()); ASSERT_FALSE(FromProto->isThisDeclarationADefinition()); - Decl *ImportedDef = Import(FromDef, Lang_CXX); - Decl *ImportedProto = Import(FromProto, Lang_CXX); + Decl *ImportedDef = Import(FromDef, Lang_CXX03); + Decl *ImportedProto = Import(FromProto, Lang_CXX03); Decl *ToTU = ImportedDef->getTranslationUnitDecl(); EXPECT_NE(ImportedDef, ImportedProto); @@ -349,16 +349,16 @@ } void TypedTest_ImportPrototypeThenDefinition() { - Decl *FromTUProto = getTuDecl(getPrototype(), Lang_CXX, "input0.cc"); - Decl *FromTUDef = getTuDecl(getDefinition(), Lang_CXX, "input1.cc"); + Decl *FromTUProto = getTuDecl(getPrototype(), Lang_CXX03, "input0.cc"); + Decl *FromTUDef = getTuDecl(getDefinition(), Lang_CXX03, "input1.cc"); auto *FromProto = FirstDeclMatcher().match(FromTUProto, getPattern()); auto *FromDef = FirstDeclMatcher().match(FromTUDef, getPattern()); ASSERT_TRUE(FromDef->isThisDeclarationADefinition()); ASSERT_FALSE(FromProto->isThisDeclarationADefinition()); - Decl *ImportedProto = Import(FromProto, Lang_CXX); - Decl *ImportedDef = Import(FromDef, Lang_CXX); + Decl *ImportedProto = Import(FromProto, Lang_CXX03); + Decl *ImportedDef = Import(FromDef, Lang_CXX03); Decl *ToTU = ImportedDef->getTranslationUnitDecl(); EXPECT_NE(ImportedDef, ImportedProto); @@ -374,12 +374,12 @@ } void TypedTest_WholeRedeclChainIsImportedAtOnce() { - Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX); + Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX03); auto *FromD = // Definition LastDeclMatcher().match(FromTU, getPattern()); ASSERT_TRUE(FromD->isThisDeclarationADefinition()); - Decl *ImportedD = Import(FromD, Lang_CXX); + Decl *ImportedD = Import(FromD, Lang_CXX03); Decl *ToTU = ImportedD->getTranslationUnitDecl(); // The whole redecl chain is imported at once. @@ -389,15 +389,15 @@ void TypedTest_ImportPrototypeThenProtoAndDefinition() { { - Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, getPattern()); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } { Decl *FromTU = - getTuDecl(getPrototype() + getDefinition(), Lang_CXX, "input1.cc"); + getTuDecl(getPrototype() + getDefinition(), Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, getPattern()); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); diff --git a/clang/unittests/AST/ASTImporterODRStrategiesTest.cpp b/clang/unittests/AST/ASTImporterODRStrategiesTest.cpp --- a/clang/unittests/AST/ASTImporterODRStrategiesTest.cpp +++ b/clang/unittests/AST/ASTImporterODRStrategiesTest.cpp @@ -37,7 +37,7 @@ BindableMatcher getPattern() { return functionDecl(hasName("X"), unless(isImplicit())); } - TestLanguage getLang() { return Lang_C; } + TestLanguage getLang() { return Lang_C99; } }; struct Typedef { @@ -45,7 +45,7 @@ static constexpr auto *Definition = "typedef int X;"; static constexpr auto *ConflictingDefinition = "typedef double X;"; BindableMatcher getPattern() { return typedefNameDecl(hasName("X")); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; struct TypedefAlias { @@ -61,7 +61,7 @@ static constexpr auto *Definition = "enum X { a, b };"; static constexpr auto *ConflictingDefinition = "enum X { a, b, c };"; BindableMatcher getPattern() { return enumDecl(hasName("X")); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; struct EnumClass { @@ -77,7 +77,7 @@ static constexpr auto *Definition = "enum E { X = 0 };"; static constexpr auto *ConflictingDefinition = "enum E { X = 1 };"; BindableMatcher getPattern() { return enumConstantDecl(hasName("X")); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; struct Class { @@ -88,7 +88,7 @@ BindableMatcher getPattern() { return cxxRecordDecl(hasName("X"), unless(isImplicit())); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; struct Variable { @@ -98,7 +98,7 @@ static constexpr auto *Definition = "int X;"; static constexpr auto *ConflictingDefinition = "float X;"; BindableMatcher getPattern() { return varDecl(hasName("X")); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; struct ClassTemplate { @@ -112,7 +112,7 @@ BindableMatcher getPattern() { return classTemplateDecl(hasName("X"), unless(isImplicit())); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; struct FunctionTemplate { @@ -133,7 +133,7 @@ } static std::string getDef0() { return Definition0; } static std::string getDef1() { return Definition1; } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; static const internal::VariadicDynCastAllOfMatcher @@ -175,7 +175,7 @@ BindableMatcher getPattern() { return classTemplateSpecializationDecl(hasName("X"), unless(isImplicit())); } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; // Function template specializations are all "full" specializations. @@ -208,7 +208,7 @@ } static std::string getDef0() { return Definition0; } static std::string getDef1() { return Definition1; } - TestLanguage getLang() { return Lang_CXX; } + TestLanguage getLang() { return Lang_CXX03; } }; static const internal::VariadicDynCastAllOfMatcher< diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -264,7 +264,7 @@ struct CanonicalRedeclChain : ASTImporterOptionSpecificTestBase {}; TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) { - Decl *FromTU = getTuDecl("void f();", Lang_CXX); + Decl *FromTU = getTuDecl("void f();", Lang_CXX03); auto Pattern = functionDecl(hasName("f")); auto *D0 = FirstDeclMatcher().match(FromTU, Pattern); @@ -274,7 +274,7 @@ } TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers2) { - Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX); + Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX03); auto Pattern = functionDecl(hasName("f")); auto *D0 = FirstDeclMatcher().match(FromTU, Pattern); auto *D2 = LastDeclMatcher().match(FromTU, Pattern); @@ -288,7 +288,7 @@ } TEST_P(CanonicalRedeclChain, ShouldBeSameForAllDeclInTheChain) { - Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX); + Decl *FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX03); auto Pattern = functionDecl(hasName("f")); auto *D0 = FirstDeclMatcher().match(FromTU, Pattern); auto *D2 = LastDeclMatcher().match(FromTU, Pattern); @@ -341,8 +341,8 @@ TEST_P(RedirectingImporterTest, InterceptImport) { Decl *From, *To; std::tie(From, To) = - getImportedDecl("class shouldNotBeImported {};", Lang_CXX, - "class realDecl {};", Lang_CXX, "shouldNotBeImported"); + getImportedDecl("class shouldNotBeImported {};", Lang_CXX03, + "class realDecl {};", Lang_CXX03, "shouldNotBeImported"); auto *Imported = cast(To); EXPECT_EQ(Imported->getQualifiedNameAsString(), "realDecl"); @@ -361,7 +361,7 @@ std::tie(From, To) = getImportedDecl("class shouldNotBeImported {};" "class F { shouldNotBeImported f; };", - Lang_CXX, "class realDecl {};", Lang_CXX, "F"); + Lang_CXX03, "class realDecl {};", Lang_CXX03, "F"); // Make sure our ASTImporter prevented the importing of the decl. auto *ToTU = To->getTranslationUnitDecl(); @@ -375,7 +375,7 @@ Decl *FromTU; FunctionDecl *D0, *D1, *D2; ImportPath() { - FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX); + FromTU = getTuDecl("void f(); void f(); void f();", Lang_CXX03); auto Pattern = functionDecl(hasName("f")); D0 = FirstDeclMatcher().match(FromTU, Pattern); D2 = LastDeclMatcher().match(FromTU, Pattern); @@ -473,21 +473,18 @@ TEST_P(ImportExpr, ImportStringLiteral) { MatchVerifier Verifier; - testImport( - "void declToImport() { (void)\"foo\"; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - stringLiteral(hasType(asString("const char [4]")))))); - testImport( - "void declToImport() { (void)L\"foo\"; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - stringLiteral(hasType(asString("const wchar_t [4]")))))); - testImport( - "void declToImport() { (void) \"foo\" \"bar\"; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - stringLiteral(hasType(asString("const char [7]")))))); + testImport("void declToImport() { (void)\"foo\"; }", Lang_CXX03, "", + Lang_CXX03, Verifier, + functionDecl(hasDescendant( + stringLiteral(hasType(asString("const char [4]")))))); + testImport("void declToImport() { (void)L\"foo\"; }", Lang_CXX03, "", + Lang_CXX03, Verifier, + functionDecl(hasDescendant( + stringLiteral(hasType(asString("const wchar_t [4]")))))); + testImport("void declToImport() { (void) \"foo\" \"bar\"; }", Lang_CXX03, "", + Lang_CXX03, Verifier, + functionDecl(hasDescendant( + stringLiteral(hasType(asString("const char [7]")))))); } TEST_P(ImportExpr, ImportChooseExpr) { @@ -495,18 +492,16 @@ // This case tests C code that is not condition-dependent and has a true // condition. - testImport( - "void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }", - Lang_C, "", Lang_C, Verifier, - functionDecl(hasDescendant(chooseExpr()))); + testImport("void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }", + Lang_C99, "", Lang_C99, Verifier, + functionDecl(hasDescendant(chooseExpr()))); } TEST_P(ImportExpr, ImportGNUNullExpr) { MatchVerifier Verifier; - testImport( - "void declToImport() { (void)__null; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger()))))); + testImport("void declToImport() { (void)__null; }", Lang_CXX03, "", + Lang_CXX03, Verifier, + functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger()))))); } TEST_P(ImportExpr, ImportCXXNullPtrLiteralExpr) { @@ -520,23 +515,21 @@ TEST_P(ImportExpr, ImportFloatinglLiteralExpr) { MatchVerifier Verifier; - testImport( - "void declToImport() { (void)1.0; }", - Lang_C, "", Lang_C, Verifier, - functionDecl(hasDescendant( - floatLiteral(equals(1.0), hasType(asString("double")))))); - testImport( - "void declToImport() { (void)1.0e-5f; }", - Lang_C, "", Lang_C, Verifier, - functionDecl(hasDescendant( - floatLiteral(equals(1.0e-5f), hasType(asString("float")))))); + testImport("void declToImport() { (void)1.0; }", Lang_C99, "", Lang_C99, + Verifier, + functionDecl(hasDescendant( + floatLiteral(equals(1.0), hasType(asString("double")))))); + testImport("void declToImport() { (void)1.0e-5f; }", Lang_C99, "", Lang_C99, + Verifier, + functionDecl(hasDescendant( + floatLiteral(equals(1.0e-5f), hasType(asString("float")))))); } TEST_P(ImportFixedPointExpr, ImportFixedPointerLiteralExpr) { MatchVerifier Verifier; - testImport("void declToImport() { (void)1.0k; }", Lang_C, "", Lang_C, + testImport("void declToImport() { (void)1.0k; }", Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant(fixedPointLiteral()))); - testImport("void declToImport() { (void)0.75r; }", Lang_C, "", Lang_C, + testImport("void declToImport() { (void)0.75r; }", Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant(fixedPointLiteral()))); } @@ -550,60 +543,47 @@ TEST_P(ImportExpr, ImportCompoundLiteralExpr) { MatchVerifier Verifier; - testImport( - "void declToImport() {" - " struct s { int x; long y; unsigned z; }; " - " (void)(struct s){ 42, 0L, 1U }; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - compoundLiteralExpr( - hasType(asString("struct s")), - has(initListExpr( - hasType(asString("struct s")), - has(integerLiteral( - equals(42), hasType(asString("int")))), - has(integerLiteral( - equals(0), hasType(asString("long")))), - has(integerLiteral( - equals(1), hasType(asString("unsigned int")))))))))); + testImport("void declToImport() {" + " struct s { int x; long y; unsigned z; }; " + " (void)(struct s){ 42, 0L, 1U }; }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionDecl(hasDescendant(compoundLiteralExpr( + hasType(asString("struct s")), + has(initListExpr( + hasType(asString("struct s")), + has(integerLiteral(equals(42), hasType(asString("int")))), + has(integerLiteral(equals(0), hasType(asString("long")))), + has(integerLiteral( + equals(1), hasType(asString("unsigned int")))))))))); } TEST_P(ImportExpr, ImportCXXThisExpr) { MatchVerifier Verifier; - testImport( - "class declToImport { void f() { (void)this; } };", - Lang_CXX, "", Lang_CXX, Verifier, - cxxRecordDecl( - hasMethod( - hasDescendant( - cxxThisExpr( - hasType( - asString("class declToImport *"))))))); + testImport("class declToImport { void f() { (void)this; } };", Lang_CXX03, "", + Lang_CXX03, Verifier, + cxxRecordDecl(hasMethod(hasDescendant( + cxxThisExpr(hasType(asString("class declToImport *"))))))); } TEST_P(ImportExpr, ImportAtomicExpr) { MatchVerifier Verifier; - testImport( - "void declToImport() { int *ptr; __atomic_load_n(ptr, 1); }", - Lang_C, "", Lang_C, Verifier, - functionDecl(hasDescendant( - atomicExpr( - has(ignoringParenImpCasts( - declRefExpr(hasDeclaration(varDecl(hasName("ptr"))), - hasType(asString("int *"))))), - has(integerLiteral(equals(1), hasType(asString("int")))))))); + testImport("void declToImport() { int *ptr; __atomic_load_n(ptr, 1); }", + Lang_C99, "", Lang_C99, Verifier, + functionDecl(hasDescendant(atomicExpr( + has(ignoringParenImpCasts( + declRefExpr(hasDeclaration(varDecl(hasName("ptr"))), + hasType(asString("int *"))))), + has(integerLiteral(equals(1), hasType(asString("int")))))))); } TEST_P(ImportExpr, ImportLabelDeclAndAddrLabelExpr) { MatchVerifier Verifier; - testImport( - "void declToImport() { loop: goto loop; (void)&&loop; }", - Lang_C, "", Lang_C, Verifier, - functionDecl( - hasDescendant( - labelStmt(hasDeclaration(labelDecl(hasName("loop"))))), - hasDescendant( - addrLabelExpr(hasDeclaration(labelDecl(hasName("loop"))))))); + testImport("void declToImport() { loop: goto loop; (void)&&loop; }", Lang_C99, + "", Lang_C99, Verifier, + functionDecl(hasDescendant(labelStmt( + hasDeclaration(labelDecl(hasName("loop"))))), + hasDescendant(addrLabelExpr( + hasDeclaration(labelDecl(hasName("loop"))))))); } AST_MATCHER_P(TemplateDecl, hasTemplateDecl, @@ -618,7 +598,7 @@ "template class dummy { void f() { dummy X(*this); } };" "typedef dummy declToImport;" "template class dummy;", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, typedefDecl(hasType(templateSpecializationType( hasDeclaration(classTemplateSpecializationDecl(hasSpecializedTemplate( classTemplateDecl(hasTemplateDecl(cxxRecordDecl(hasMethod(allOf( @@ -631,18 +611,17 @@ TEST_P(ImportExpr, ImportSwitch) { MatchVerifier Verifier; - testImport( - "void declToImport() { int b; switch (b) { case 1: break; } }", - Lang_C, "", Lang_C, Verifier, - functionDecl(hasDescendant( - switchStmt(has(compoundStmt(has(caseStmt()))))))); + testImport("void declToImport() { int b; switch (b) { case 1: break; } }", + Lang_C99, "", Lang_C99, Verifier, + functionDecl(hasDescendant( + switchStmt(has(compoundStmt(has(caseStmt()))))))); } TEST_P(ImportExpr, ImportStmtExpr) { MatchVerifier Verifier; testImport( "void declToImport() { int b; int a = b ?: 1; int C = ({int X=4; X;}); }", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, traverse(ast_type_traits::TK_AsIs, functionDecl(hasDescendant(varDecl( hasName("C"), hasType(asString("int")), @@ -655,22 +634,19 @@ TEST_P(ImportExpr, ImportConditionalOperator) { MatchVerifier Verifier; - testImport( - "void declToImport() { (void)(true ? 1 : -5); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - conditionalOperator( - hasCondition(cxxBoolLiteral(equals(true))), - hasTrueExpression(integerLiteral(equals(1))), - hasFalseExpression( - unaryOperator(hasUnaryOperand(integerLiteral(equals(5)))))) - ))); + testImport("void declToImport() { (void)(true ? 1 : -5); }", Lang_CXX03, "", + Lang_CXX03, Verifier, + functionDecl(hasDescendant(conditionalOperator( + hasCondition(cxxBoolLiteral(equals(true))), + hasTrueExpression(integerLiteral(equals(1))), + hasFalseExpression(unaryOperator( + hasUnaryOperand(integerLiteral(equals(5))))))))); } TEST_P(ImportExpr, ImportBinaryConditionalOperator) { MatchVerifier Verifier; testImport( - "void declToImport() { (void)(1 ?: -5); }", Lang_CXX, "", Lang_CXX, + "void declToImport() { (void)(1 ?: -5); }", Lang_CXX03, "", Lang_CXX03, Verifier, traverse(ast_type_traits::TK_AsIs, functionDecl(hasDescendant(binaryConditionalOperator( @@ -692,35 +668,27 @@ " struct point { double x; double y; };" " struct point ptarray[10] = " "{ [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; }", - Lang_C, "", Lang_C, Verifier, - functionDecl(hasDescendant( - initListExpr( - has(designatedInitExpr( - designatorCountIs(2), - hasDescendant(floatLiteral(equals(1.0))), - hasDescendant(integerLiteral(equals(2))))), - has(designatedInitExpr( - designatorCountIs(2), - hasDescendant(floatLiteral(equals(2.0))), - hasDescendant(integerLiteral(equals(2))))), - has(designatedInitExpr( - designatorCountIs(2), - hasDescendant(floatLiteral(equals(1.0))), - hasDescendant(integerLiteral(equals(0))))))))); + Lang_C99, "", Lang_C99, Verifier, + functionDecl(hasDescendant(initListExpr( + has(designatedInitExpr(designatorCountIs(2), + hasDescendant(floatLiteral(equals(1.0))), + hasDescendant(integerLiteral(equals(2))))), + has(designatedInitExpr(designatorCountIs(2), + hasDescendant(floatLiteral(equals(2.0))), + hasDescendant(integerLiteral(equals(2))))), + has(designatedInitExpr(designatorCountIs(2), + hasDescendant(floatLiteral(equals(1.0))), + hasDescendant(integerLiteral(equals(0))))))))); } TEST_P(ImportExpr, ImportPredefinedExpr) { MatchVerifier Verifier; // __func__ expands as StringLiteral("declToImport") - testImport( - "void declToImport() { (void)__func__; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - predefinedExpr( - hasType( - asString("const char [13]")), - has(stringLiteral(hasType( - asString("const char [13]")))))))); + testImport("void declToImport() { (void)__func__; }", Lang_CXX03, "", + Lang_CXX03, Verifier, + functionDecl(hasDescendant(predefinedExpr( + hasType(asString("const char [13]")), + has(stringLiteral(hasType(asString("const char [13]")))))))); } TEST_P(ImportExpr, ImportInitListExpr) { @@ -730,23 +698,15 @@ " struct point { double x; double y; };" " point ptarray[10] = { [2].y = 1.0, [2].x = 2.0," " [0].x = 1.0 }; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - initListExpr( - has( - cxxConstructExpr( - requiresZeroInitialization())), - has( - initListExpr( - hasType(asString("struct point")), - has(floatLiteral(equals(1.0))), - has(implicitValueInitExpr( - hasType(asString("double")))))), - has( - initListExpr( - hasType(asString("struct point")), - has(floatLiteral(equals(2.0))), - has(floatLiteral(equals(1.0))))))))); + Lang_CXX03, "", Lang_CXX03, Verifier, + functionDecl(hasDescendant(initListExpr( + has(cxxConstructExpr(requiresZeroInitialization())), + has(initListExpr( + hasType(asString("struct point")), has(floatLiteral(equals(1.0))), + has(implicitValueInitExpr(hasType(asString("double")))))), + has(initListExpr(hasType(asString("struct point")), + has(floatLiteral(equals(2.0))), + has(floatLiteral(equals(1.0))))))))); } @@ -754,12 +714,11 @@ TEST_P(ImportExpr, ImportVAArgExpr) { MatchVerifier Verifier; - testImport( - "void declToImport(__builtin_va_list list, ...) {" - " (void)__builtin_va_arg(list, int); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - cStyleCastExpr(hasSourceExpression(vaArgExpr()))))); + testImport("void declToImport(__builtin_va_list list, ...) {" + " (void)__builtin_va_arg(list, int); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionDecl(hasDescendant( + cStyleCastExpr(hasSourceExpression(vaArgExpr()))))); } TEST_P(ImportExpr, CXXTemporaryObjectExpr) { @@ -767,7 +726,7 @@ testImport( "struct C {};" "void declToImport() { C c = C(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, traverse(ast_type_traits::TK_AsIs, functionDecl(hasDescendant(exprWithCleanups(has(cxxConstructExpr( has(materializeTemporaryExpr(has(implicitCastExpr( @@ -784,34 +743,30 @@ TEST_P(ImportDecl, ImportFunctionTemplateDecl) { MatchVerifier Verifier; - testImport( - "template void declToImport() { };", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl()); + testImport("template void declToImport() { };", Lang_CXX03, "", + Lang_CXX03, Verifier, functionTemplateDecl()); } TEST_P(ImportExpr, ImportCXXDependentScopeMemberExpr) { MatchVerifier Verifier; - testImport( - "template struct C { T t; };" - "template void declToImport() {" - " C d;" - " (void)d.t;" - "}" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl(hasDescendant( - cStyleCastExpr(has(cxxDependentScopeMemberExpr()))))); - testImport( - "template struct C { T t; };" - "template void declToImport() {" - " C d;" - " (void)(&d)->t;" - "}" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl(hasDescendant( - cStyleCastExpr(has(cxxDependentScopeMemberExpr()))))); + testImport("template struct C { T t; };" + "template void declToImport() {" + " C d;" + " (void)d.t;" + "}" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionTemplateDecl(hasDescendant( + cStyleCastExpr(has(cxxDependentScopeMemberExpr()))))); + testImport("template struct C { T t; };" + "template void declToImport() {" + " C d;" + " (void)(&d)->t;" + "}" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionTemplateDecl(hasDescendant( + cStyleCastExpr(has(cxxDependentScopeMemberExpr()))))); } TEST_P(ImportType, ImportTypeAliasTemplate) { @@ -864,16 +819,15 @@ TEST_P(ImportType, ImportDependentTemplateSpecialization) { MatchVerifier Verifier; - testImport( - "template" - "struct A;" - "template" - "struct declToImport {" - " typename A::template B a;" - "};", - Lang_CXX, "", Lang_CXX, Verifier, - classTemplateDecl(has(cxxRecordDecl(has( - fieldDecl(hasType(dependentTemplateSpecializationType()))))))); + testImport("template" + "struct A;" + "template" + "struct declToImport {" + " typename A::template B a;" + "};", + Lang_CXX03, "", Lang_CXX03, Verifier, + classTemplateDecl(has(cxxRecordDecl(has( + fieldDecl(hasType(dependentTemplateSpecializationType()))))))); } const internal::VariadicDynCastAllOfMatcher @@ -917,7 +871,7 @@ "void declToImport() { " " (void)__builtin_types_compatible_p(int, int);" "}", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant(typeTraitExpr(hasType(asString("int")))))); } @@ -961,7 +915,7 @@ " struct data_t d;" " return 0;" "}", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasBody(compoundStmt( has(declStmt(hasSingleDecl(varDecl(hasName("d"))))))))); } @@ -972,12 +926,12 @@ " struct data_t d;" " return 0;" "}", - Lang_C, "input.c"); + Lang_C99, "input.c"); auto *FromVar = FirstDeclMatcher().match(FromTU, varDecl(hasName("d"))); ASSERT_TRUE(FromVar); auto ToType = - ImportType(FromVar->getType().getCanonicalType(), FromVar, Lang_C); + ImportType(FromVar->getType().getCanonicalType(), FromVar, Lang_C99); EXPECT_FALSE(ToType.isNull()); } @@ -985,23 +939,23 @@ // This construct is not supported by ASTImporter. Decl *FromTU = getTuDecl( "int declToImport(struct data_t{int a;int b;} ***d){ return 0; }", - Lang_C, "input.c"); + Lang_C99, "input.c"); auto *From = FirstDeclMatcher().match( FromTU, functionDecl(hasName("declToImport"))); ASSERT_TRUE(From); - auto *To = Import(From, Lang_C); + auto *To = Import(From, Lang_C99); EXPECT_EQ(To, nullptr); } TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordDeclInFuncFromMacro) { - Decl *FromTU = getTuDecl( - "#define NONAME_SIZEOF(type) sizeof(struct{type *dummy;}) \n" - "int declToImport(){ return NONAME_SIZEOF(int); }", - Lang_C, "input.c"); + Decl *FromTU = + getTuDecl("#define NONAME_SIZEOF(type) sizeof(struct{type *dummy;}) \n" + "int declToImport(){ return NONAME_SIZEOF(int); }", + Lang_C99, "input.c"); auto *From = FirstDeclMatcher().match( FromTU, functionDecl(hasName("declToImport"))); ASSERT_TRUE(From); - auto *To = Import(From, Lang_C); + auto *To = Import(From, Lang_C99); ASSERT_TRUE(To); EXPECT_TRUE(MatchVerifier().match( To, functionDecl(hasName("declToImport"), @@ -1011,14 +965,14 @@ 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" - "int declToImport(PAIR_STRUCT(int) ***d){ return 0; }", - Lang_C, "input.c"); + Decl *FromTU = + getTuDecl("#define PAIR_STRUCT(type) struct data_t{type a;type b;} \n" + "int declToImport(PAIR_STRUCT(int) ***d){ return 0; }", + Lang_C99, "input.c"); auto *From = FirstDeclMatcher().match( FromTU, functionDecl(hasName("declToImport"))); ASSERT_TRUE(From); - auto *To = Import(From, Lang_C); + auto *To = Import(From, Lang_C99); EXPECT_EQ(To, nullptr); } @@ -1033,18 +987,16 @@ " T t;" " p->T::~T();" "}", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant( - callExpr(has(cxxPseudoDestructorExpr()))))); + Lang_CXX03, "", Lang_CXX03, Verifier, + functionDecl(hasDescendant(callExpr(has(cxxPseudoDestructorExpr()))))); } TEST_P(ImportDecl, ImportUsingDecl) { MatchVerifier Verifier; - testImport( - "namespace foo { int bar; }" - "void declToImport() { using foo::bar; }", - Lang_CXX, "", Lang_CXX, Verifier, - functionDecl(hasDescendant(usingDecl()))); + testImport("namespace foo { int bar; }" + "void declToImport() { using foo::bar; }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionDecl(hasDescendant(usingDecl()))); } /// \brief Matches shadow declarations introduced into a scope by a @@ -1062,48 +1014,44 @@ TEST_P(ImportDecl, ImportUsingShadowDecl) { MatchVerifier Verifier; - testImport( - "namespace foo { int bar; }" - "namespace declToImport { using foo::bar; }", - Lang_CXX, "", Lang_CXX, Verifier, - namespaceDecl(has(usingShadowDecl()))); + testImport("namespace foo { int bar; }" + "namespace declToImport { using foo::bar; }", + Lang_CXX03, "", Lang_CXX03, Verifier, + namespaceDecl(has(usingShadowDecl()))); } TEST_P(ImportExpr, ImportUnresolvedLookupExpr) { MatchVerifier Verifier; - testImport( - "template int foo();" - "template void declToImport() {" - " (void)::foo;" - " (void)::template foo;" - "}" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl(hasDescendant(unresolvedLookupExpr()))); + testImport("template int foo();" + "template void declToImport() {" + " (void)::foo;" + " (void)::template foo;" + "}" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionTemplateDecl(hasDescendant(unresolvedLookupExpr()))); } TEST_P(ImportExpr, ImportCXXUnresolvedConstructExpr) { MatchVerifier Verifier; - testImport( - "template struct C { T t; };" - "template void declToImport() {" - " C d;" - " d.t = T();" - "}" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl(hasDescendant( - binaryOperator(has(cxxUnresolvedConstructExpr()))))); - testImport( - "template struct C { T t; };" - "template void declToImport() {" - " C d;" - " (&d)->t = T();" - "}" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl(hasDescendant( - binaryOperator(has(cxxUnresolvedConstructExpr()))))); + testImport("template struct C { T t; };" + "template void declToImport() {" + " C d;" + " d.t = T();" + "}" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionTemplateDecl(hasDescendant( + binaryOperator(has(cxxUnresolvedConstructExpr()))))); + testImport("template struct C { T t; };" + "template void declToImport() {" + " C d;" + " (&d)->t = T();" + "}" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionTemplateDecl(hasDescendant( + binaryOperator(has(cxxUnresolvedConstructExpr()))))); } /// Check that function "declToImport()" (which is the templated function @@ -1111,18 +1059,16 @@ /// Same for class template declarations. TEST_P(ImportDecl, ImportTemplatedDeclForTemplate) { MatchVerifier Verifier; - testImport( - "template void declToImport() { T a = 1; }" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - functionTemplateDecl(hasAncestor(translationUnitDecl( - unless(has(functionDecl(hasName("declToImport")))))))); - testImport( - "template struct declToImport { T t; };" - "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, - classTemplateDecl(hasAncestor(translationUnitDecl( - unless(has(cxxRecordDecl(hasName("declToImport")))))))); + testImport("template void declToImport() { T a = 1; }" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + functionTemplateDecl(hasAncestor(translationUnitDecl( + unless(has(functionDecl(hasName("declToImport")))))))); + testImport("template struct declToImport { T t; };" + "void instantiate() { declToImport(); }", + Lang_CXX03, "", Lang_CXX03, Verifier, + classTemplateDecl(hasAncestor(translationUnitDecl( + unless(has(cxxRecordDecl(hasName("declToImport")))))))); } TEST_P(ImportDecl, ImportClassTemplatePartialSpecialization) { @@ -1134,7 +1080,7 @@ template struct X {}; }; )s"; - testImport(Code, Lang_CXX, "", Lang_CXX, Verifier, + testImport(Code, Lang_CXX03, "", Lang_CXX03, Verifier, recordDecl(has(classTemplateDecl()), has(classTemplateSpecializationDecl()))); } @@ -1145,25 +1091,24 @@ "class declToImport {" " void f() { *this = declToImport(); }" "};", - Lang_CXX, "", Lang_CXX, Verifier, - cxxRecordDecl(has(cxxMethodDecl(hasDescendant( - cxxOperatorCallExpr()))))); + Lang_CXX03, "", Lang_CXX03, Verifier, + cxxRecordDecl(has(cxxMethodDecl(hasDescendant(cxxOperatorCallExpr()))))); } TEST_P(ImportExpr, DependentSizedArrayType) { MatchVerifier Verifier; - testImport( - "template class declToImport {" - " T data[Size];" - "};", - Lang_CXX, "", Lang_CXX, Verifier, - classTemplateDecl(has(cxxRecordDecl( - has(fieldDecl(hasType(dependentSizedArrayType()))))))); + testImport("template class declToImport {" + " T data[Size];" + "};", + Lang_CXX03, "", Lang_CXX03, Verifier, + classTemplateDecl(has(cxxRecordDecl( + has(fieldDecl(hasType(dependentSizedArrayType()))))))); } TEST_P(ASTImporterOptionSpecificTestBase, ImportBeginLocOfDeclRefExpr) { - Decl *FromTU = getTuDecl( - "class A { public: static int X; }; void f() { (void)A::X; }", Lang_CXX); + Decl *FromTU = + getTuDecl("class A { public: static int X; }; void f() { (void)A::X; }", + Lang_CXX03); auto From = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); ASSERT_TRUE(From); @@ -1172,7 +1117,7 @@ ->getSubExpr() ->getBeginLoc() .isValid()); - FunctionDecl *To = Import(From, Lang_CXX); + FunctionDecl *To = Import(From, Lang_CXX03); ASSERT_TRUE(To); ASSERT_TRUE( cast(cast(To->getBody())->body_front()) @@ -1183,41 +1128,41 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclOfClassTemplateDecl) { - Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX); + Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03); auto From = FirstDeclMatcher().match(FromTU, classTemplateDecl()); ASSERT_TRUE(From); - auto To = cast(Import(From, Lang_CXX)); + auto To = cast(Import(From, Lang_CXX03)); ASSERT_TRUE(To); Decl *ToTemplated = To->getTemplatedDecl(); - Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX); + Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX03); EXPECT_TRUE(ToTemplated1); EXPECT_EQ(ToTemplated1, ToTemplated); } TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclOfFunctionTemplateDecl) { - Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX); + Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX03); auto From = FirstDeclMatcher().match( FromTU, functionTemplateDecl()); ASSERT_TRUE(From); - auto To = cast(Import(From, Lang_CXX)); + auto To = cast(Import(From, Lang_CXX03)); ASSERT_TRUE(To); Decl *ToTemplated = To->getTemplatedDecl(); - Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX); + Decl *ToTemplated1 = Import(From->getTemplatedDecl(), Lang_CXX03); EXPECT_TRUE(ToTemplated1); EXPECT_EQ(ToTemplated1, ToTemplated); } TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclShouldImportTheClassTemplateDecl) { - Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX); + Decl *FromTU = getTuDecl("template struct S{};", Lang_CXX03); auto FromFT = FirstDeclMatcher().match(FromTU, classTemplateDecl()); ASSERT_TRUE(FromFT); auto ToTemplated = - cast(Import(FromFT->getTemplatedDecl(), Lang_CXX)); + cast(Import(FromFT->getTemplatedDecl(), Lang_CXX03)); EXPECT_TRUE(ToTemplated); auto ToTU = ToTemplated->getTranslationUnitDecl(); auto ToFT = @@ -1227,13 +1172,13 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfTemplatedDeclShouldImportTheFunctionTemplateDecl) { - Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX); + Decl *FromTU = getTuDecl("template void f(){}", Lang_CXX03); auto FromFT = FirstDeclMatcher().match( FromTU, functionTemplateDecl()); ASSERT_TRUE(FromFT); auto ToTemplated = - cast(Import(FromFT->getTemplatedDecl(), Lang_CXX)); + cast(Import(FromFT->getTemplatedDecl(), Lang_CXX03)); EXPECT_TRUE(ToTemplated); auto ToTU = ToTemplated->getTranslationUnitDecl(); auto ToFT = FirstDeclMatcher().match( @@ -1250,10 +1195,10 @@ template struct S3{}; } )"; - Decl *FromTU = getTuDecl(Code, Lang_CXX); + Decl *FromTU = getTuDecl(Code, Lang_CXX03); auto FromNs = FirstDeclMatcher().match(FromTU, namespaceDecl()); - auto ToNs = cast(Import(FromNs, Lang_CXX)); + auto ToNs = cast(Import(FromNs, Lang_CXX03)); ASSERT_TRUE(ToNs); auto From = FirstDeclMatcher().match(FromTU, @@ -1267,7 +1212,7 @@ ASSERT_TRUE(To); auto ToTemplated = To->getTemplatedDecl(); auto ToTemplated1 = - cast(Import(From->getTemplatedDecl(), Lang_CXX)); + cast(Import(From->getTemplatedDecl(), Lang_CXX03)); EXPECT_TRUE(ToTemplated1); ASSERT_EQ(ToTemplated1, ToTemplated); } @@ -1277,8 +1222,8 @@ // gets it right. Decl *From, *To; std::tie(From, To) = getImportedDecl( - "void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }", - Lang_C, "", Lang_C); + "void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }", Lang_C99, + "", Lang_C99); auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext()); auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext()); @@ -1311,7 +1256,7 @@ } }; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; auto Matcher = functionDecl(hasName("declToImport"), @@ -1329,7 +1274,7 @@ std::tie(From, To) = getImportedDecl("template void declToImport() { T a = 1; }" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); auto Check = [](Decl *D) -> bool { auto TU = D->getTranslationUnitDecl(); @@ -1355,7 +1300,7 @@ std::tie(From, To) = getImportedDecl("template struct declToImport { T t; };" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); auto Check = [](Decl *D) -> bool { auto TU = D->getTranslationUnitDecl(); @@ -1413,7 +1358,7 @@ class Base {}; class declToImport : public Base {}; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); // Check that the ClassTemplateSpecializationDecl is NOT the child of the TU. auto Pattern = @@ -1459,7 +1404,7 @@ template class X; } )", - Lang_CXX, "", Lang_CXX, "NS"); + Lang_CXX03, "", Lang_CXX03, "NS"); // Check that the ClassTemplateSpecializationDecl is NOT the child of the // ClassTemplateDecl. @@ -1542,7 +1487,7 @@ struct declToImport { }; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; // Match the implicit Decl. @@ -1560,7 +1505,7 @@ struct declToImport { }; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; // Match the implicit Decl. @@ -1578,7 +1523,7 @@ class Base {}; class declToImport : public Base {}; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); auto hasImplicitClass = has(cxxRecordDecl()); auto Pattern = translationUnitDecl(has(classTemplateDecl( @@ -1593,7 +1538,7 @@ TEST_P(ASTImporterOptionSpecificTestBase, IDNSOrdinary) { Decl *From, *To; std::tie(From, To) = - getImportedDecl("void declToImport() {}", Lang_CXX, "", Lang_CXX); + getImportedDecl("void declToImport() {}", Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; auto Matcher = functionDecl(); @@ -1608,9 +1553,9 @@ struct X {}; void operator<<(int, X); )", - Lang_CXX); + Lang_CXX03); Decl *From = LastDeclMatcher{}.match(FromTU, functionDecl()); - const Decl *To = Import(From, Lang_CXX); + const Decl *To = Import(From, Lang_CXX03); EXPECT_EQ(From->getIdentifierNamespace(), To->getIdentifierNamespace()); } @@ -1623,7 +1568,7 @@ class Base { int a; }; class declToImport : Base {}; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); auto Pattern = translationUnitDecl(has(classTemplateDecl( hasName("Base"), @@ -1642,11 +1587,11 @@ template struct B; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, classTemplateDecl(hasName("B"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } { @@ -1657,13 +1602,13 @@ void f(); }; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); FunctionDecl *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); auto *FromCTD = FirstDeclMatcher().match( FromTU, classTemplateDecl(hasName("B"))); - auto *ToCTD = cast(Import(FromCTD, Lang_CXX)); + auto *ToCTD = cast(Import(FromCTD, Lang_CXX03)); EXPECT_TRUE(ToCTD->isThisDeclarationADefinition()); } } @@ -1680,7 +1625,7 @@ template struct B; )", - Lang_CXX); + Lang_CXX03); ASSERT_EQ(1u, DeclCounterWithPredicate( [](const ClassTemplateDecl *T) { return T->isThisDeclarationADefinition(); @@ -1694,11 +1639,11 @@ void f(); }; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); ClassTemplateDecl *FromD = FirstDeclMatcher().match( FromTU, classTemplateDecl(hasName("B"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); // We should have only one definition. EXPECT_EQ(1u, DeclCounterWithPredicate( @@ -1718,7 +1663,7 @@ struct B; )", - Lang_CXX); + Lang_CXX03); ASSERT_EQ(2u, DeclCounter().match( ToTU, cxxRecordDecl(unless(isImplicit())))); @@ -1728,11 +1673,11 @@ void f(); }; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("B"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); EXPECT_EQ(2u, DeclCounter().match( ToTU, cxxRecordDecl(unless(isImplicit())))); @@ -1761,9 +1706,9 @@ MFOO(a); } )", - Lang_CXX); + Lang_CXX03); auto FromD = FirstDeclMatcher().match(FromTU, functionDecl()); - auto ToD = Import(FromD, Lang_CXX); + auto ToD = Import(FromD, Lang_CXX03); auto ToLHS = LastDeclMatcher().match(ToD, declRefExpr()); auto FromLHS = LastDeclMatcher().match(FromTU, declRefExpr()); @@ -1788,9 +1733,9 @@ #define FUNC FUNC_INT FUNC(int a); )", - Lang_CXX); + Lang_CXX03); auto FromD = FirstDeclMatcher().match(FromTU, functionDecl()); - auto ToD = Import(FromD, Lang_CXX); + auto ToD = Import(FromD, Lang_CXX03); SourceManager &ToSM = ToAST->getASTContext().getSourceManager(); SourceManager &FromSM = FromD->getASTContext().getSourceManager(); @@ -1812,7 +1757,7 @@ template <> struct B; )", - Lang_CXX); + Lang_CXX03); // We should have only one definition. ASSERT_EQ(1u, DeclCounterWithPredicate( [](const ClassTemplateSpecializationDecl *T) { @@ -1828,11 +1773,11 @@ template <> struct B {}; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, classTemplateSpecializationDecl(hasName("B"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); // We should have only one definition. EXPECT_EQ(1u, DeclCounterWithPredicate( @@ -1848,7 +1793,7 @@ struct { int a; int b; } object0 = { 2, 3 }; struct { int x; int y; int z; } object1; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *Obj0 = FirstDeclMatcher().match(FromTU, varDecl(hasName("object0"))); @@ -1857,8 +1802,8 @@ FirstDeclMatcher().match(FromTU, varDecl(hasName("object1"))); auto *From1 = getRecordDecl(Obj1); - auto *To0 = Import(From0, Lang_CXX); - auto *To1 = Import(From1, Lang_CXX); + auto *To0 = Import(From0, Lang_CXX03); + auto *To1 = Import(From1, Lang_CXX03); EXPECT_TRUE(To0); EXPECT_TRUE(To1); @@ -1874,16 +1819,16 @@ struct { int b; }; }; )"; - Decl *FromTU0 = getTuDecl(Code, Lang_C, "input0.c"); + Decl *FromTU0 = getTuDecl(Code, Lang_C99, "input0.c"); - Decl *FromTU1 = getTuDecl(Code, Lang_C, "input1.c"); + Decl *FromTU1 = getTuDecl(Code, Lang_C99, "input1.c"); auto *X0 = FirstDeclMatcher().match(FromTU0, recordDecl(hasName("X"))); auto *X1 = FirstDeclMatcher().match(FromTU1, recordDecl(hasName("X"))); - Import(X0, Lang_C); - Import(X1, Lang_C); + Import(X0, Lang_C99); + Import(X1, Lang_C99); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); // We expect no (ODR) warning during the import. @@ -1900,7 +1845,7 @@ struct { int b; }; }; )", - Lang_C, "input0.c"); + Lang_C99, "input0.c"); Decl *FromTU1 = getTuDecl( R"( @@ -1909,14 +1854,14 @@ struct { int a; }; }; )", - Lang_C, "input1.c"); + Lang_C99, "input1.c"); auto *X0 = FirstDeclMatcher().match(FromTU0, recordDecl(hasName("X"))); auto *X1 = FirstDeclMatcher().match(FromTU1, recordDecl(hasName("X"))); - Import(X0, Lang_C); - Import(X1, Lang_C); + Import(X0, Lang_C99); + Import(X1, Lang_C99); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); // We expect one (ODR) warning during the import. @@ -1929,24 +1874,24 @@ auto Pattern = varDecl(hasName("x")); VarDecl *Imported1; { - Decl *FromTU = getTuDecl("extern int x;", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("extern int x;", Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - Imported1 = cast(Import(FromD, Lang_CXX)); + Imported1 = cast(Import(FromD, Lang_CXX03)); } VarDecl *Imported2; { - Decl *FromTU = getTuDecl("int x;", Lang_CXX, "input1.cc"); + Decl *FromTU = getTuDecl("int x;", Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - Imported2 = cast(Import(FromD, Lang_CXX)); + Imported2 = cast(Import(FromD, Lang_CXX03)); } EXPECT_EQ(Imported1->getCanonicalDecl(), Imported2->getCanonicalDecl()); EXPECT_FALSE(Imported2->isUsed(false)); { - Decl *FromTU = - getTuDecl("extern int x; int f() { return x; }", Lang_CXX, "input2.cc"); + Decl *FromTU = getTuDecl("extern int x; int f() { return x; }", Lang_CXX03, + "input2.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } EXPECT_TRUE(Imported2->isUsed(false)); } @@ -1955,16 +1900,16 @@ auto Pattern = varDecl(hasName("x")); VarDecl *ExistingD; { - Decl *ToTU = getToTuDecl("int x = 1;", Lang_CXX); + Decl *ToTU = getToTuDecl("int x = 1;", Lang_CXX03); ExistingD = FirstDeclMatcher().match(ToTU, Pattern); } EXPECT_FALSE(ExistingD->isUsed(false)); { - Decl *FromTU = getTuDecl( - "int x = 1; int f() { return x; }", Lang_CXX, "input1.cc"); + Decl *FromTU = + getTuDecl("int x = 1; int f() { return x; }", Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } EXPECT_TRUE(ExistingD->isUsed(false)); } @@ -1978,7 +1923,8 @@ struct A { static const int a = 1; }; - )", Lang_CXX); + )", + Lang_CXX03); ExistingD = FirstDeclMatcher().match(ToTU, Pattern); } EXPECT_FALSE(ExistingD->isUsed(false)); @@ -1990,12 +1936,13 @@ }; const int *f() { return &A::a; } // requires storage, // thus used flag will be set - )", Lang_CXX, "input1.cc"); + )", + Lang_CXX03, "input1.cc"); auto *FromFunD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); ASSERT_TRUE(FromD->isUsed(false)); - Import(FromFunD, Lang_CXX); + Import(FromFunD, Lang_CXX03); } EXPECT_TRUE(ExistingD->isUsed(false)); } @@ -2003,15 +1950,15 @@ TEST_P(ASTImporterOptionSpecificTestBase, ReimportWithUsedFlag) { auto Pattern = varDecl(hasName("x")); - Decl *FromTU = getTuDecl("int x;", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("int x;", Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - auto *Imported1 = cast(Import(FromD, Lang_CXX)); + auto *Imported1 = cast(Import(FromD, Lang_CXX03)); ASSERT_FALSE(Imported1->isUsed(false)); FromD->setIsUsed(); - auto *Imported2 = cast(Import(FromD, Lang_CXX)); + auto *Imported2 = cast(Import(FromD, Lang_CXX03)); EXPECT_EQ(Imported1, Imported2); EXPECT_TRUE(Imported2->isUsed(false)); @@ -2020,12 +1967,12 @@ struct ImportFunctions : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportFunctions, ImportPrototypeOfRecursiveFunction) { - Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX); + Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX03); auto Pattern = functionDecl(hasName("f")); auto *From = FirstDeclMatcher().match(FromTU, Pattern); // Proto - Decl *ImportedD = Import(From, Lang_CXX); + Decl *ImportedD = Import(From, Lang_CXX03); Decl *ToTU = ImportedD->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u); @@ -2038,12 +1985,12 @@ } TEST_P(ImportFunctions, ImportDefinitionOfRecursiveFunction) { - Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX); + Decl *FromTU = getTuDecl("void f(); void f() { f(); }", Lang_CXX03); auto Pattern = functionDecl(hasName("f")); auto *From = LastDeclMatcher().match(FromTU, Pattern); // Def - Decl *ImportedD = Import(From, Lang_CXX); + Decl *ImportedD = Import(From, Lang_CXX03); Decl *ToTU = ImportedD->getTranslationUnitDecl(); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u); @@ -2064,12 +2011,12 @@ )"; auto Pattern = cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("D")))); - Decl *FromTU = getTuDecl(Code, Lang_CXX); + Decl *FromTU = getTuDecl(Code, Lang_CXX03); CXXMethodDecl *Proto = FirstDeclMatcher().match(FromTU, Pattern); ASSERT_EQ(Proto->size_overridden_methods(), 1u); - CXXMethodDecl *To = cast(Import(Proto, Lang_CXX)); + CXXMethodDecl *To = cast(Import(Proto, Lang_CXX03)); EXPECT_EQ(To->size_overridden_methods(), 1u); } @@ -2081,14 +2028,14 @@ )"; auto Pattern = cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("B")))); - Decl *FromTU = getTuDecl(Code, Lang_CXX); + Decl *FromTU = getTuDecl(Code, Lang_CXX03); CXXMethodDecl *Proto = FirstDeclMatcher().match(FromTU, Pattern); CXXMethodDecl *Def = LastDeclMatcher().match(FromTU, Pattern); ASSERT_TRUE(Proto->isVirtual()); ASSERT_TRUE(Def->isVirtual()); - CXXMethodDecl *To = cast(Import(Proto, Lang_CXX)); + CXXMethodDecl *To = cast(Import(Proto, Lang_CXX03)); EXPECT_TRUE(To->isVirtual()); } @@ -2099,16 +2046,16 @@ void f() {} void f(); )", - Lang_CXX); + Lang_CXX03); ASSERT_EQ(1u, DeclCounterWithPredicate([](const FunctionDecl *FD) { return FD->doesThisDeclarationHaveABody(); }).match(ToTU, functionDecl())); - Decl *FromTU = getTuDecl("void f() {}", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("void f() {}", Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, functionDecl()); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); EXPECT_EQ(1u, DeclCounterWithPredicate([](const FunctionDecl *FD) { @@ -2127,13 +2074,13 @@ auto DFP = cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("D")))); - Decl *FromTU0 = getTuDecl(Code, Lang_CXX); + Decl *FromTU0 = getTuDecl(Code, Lang_CXX03); auto *DF = FirstDeclMatcher().match(FromTU0, DFP); - Import(DF, Lang_CXX); + Import(DF, Lang_CXX03); - Decl *FromTU1 = getTuDecl(Code, Lang_CXX, "input1.cc"); + Decl *FromTU1 = getTuDecl(Code, Lang_CXX03, "input1.cc"); auto *BF = FirstDeclMatcher().match(FromTU1, BFP); - Import(BF, Lang_CXX); + Import(BF, Lang_CXX03); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2163,14 +2110,14 @@ auto FDefAllP = cxxMethodDecl(hasName("f"), isDefinition()); { - Decl *FromTU = getTuDecl(CodeWithDef, Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl(CodeWithDef, Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, DFP); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } { - Decl *FromTU = getTuDecl(CodeWithoutDef, Lang_CXX, "input1.cc"); + Decl *FromTU = getTuDecl(CodeWithoutDef, Lang_CXX03, "input1.cc"); auto *FromB = FirstDeclMatcher().match(FromTU, BFP); - Import(FromB, Lang_CXX); + Import(FromB, Lang_CXX03); } auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2197,13 +2144,13 @@ auto DFP = cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("D"))), unless(isDefinition())); - Decl *FromTU0 = getTuDecl(Code, Lang_CXX); + Decl *FromTU0 = getTuDecl(Code, Lang_CXX03); auto *D = FirstDeclMatcher().match(FromTU0, DFP); - Import(D, Lang_CXX); + Import(D, Lang_CXX03); - Decl *FromTU1 = getTuDecl(Code, Lang_CXX, "input1.cc"); + Decl *FromTU1 = getTuDecl(Code, Lang_CXX03, "input1.cc"); auto *B = FirstDeclMatcher().match(FromTU1, BFP); - Import(B, Lang_CXX); + Import(B, Lang_CXX03); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2254,15 +2201,15 @@ auto FooDef = functionDecl(hasName("foo")); { - Decl *FromTU0 = getTuDecl(CodeTU0, Lang_CXX, "input0.cc"); + Decl *FromTU0 = getTuDecl(CodeTU0, Lang_CXX03, "input0.cc"); auto *D = FirstDeclMatcher().match(FromTU0, DFP); - Import(D, Lang_CXX); + Import(D, Lang_CXX03); } { - Decl *FromTU1 = getTuDecl(CodeTU1, Lang_CXX, "input1.cc"); + Decl *FromTU1 = getTuDecl(CodeTU1, Lang_CXX03, "input1.cc"); auto *Foo = FirstDeclMatcher().match(FromTU1, FooDef); - Import(Foo, Lang_CXX); + Import(Foo, Lang_CXX03); } auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2305,13 +2252,13 @@ std::string Code = "static int v; static int v = 0;"; auto Pattern = varDecl(hasName("v")); - TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_C, "input0.c"); + TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_C99, "input0.c"); auto *From0 = FirstDeclMatcher().match(FromTu, Pattern); auto *From1 = LastDeclMatcher().match(FromTu, Pattern); - auto *To0 = Import(From0, Lang_C); - auto *To1 = Import(From1, Lang_C); + auto *To0 = Import(From0, Lang_C99); + auto *To1 = Import(From1, Lang_C99); EXPECT_TRUE(To0); ASSERT_TRUE(To1); @@ -2320,17 +2267,17 @@ } TEST_P(ImportFunctions, ImportFromDifferentScopedAnonNamespace) { - TranslationUnitDecl *FromTu = getTuDecl( - "namespace NS0 { namespace { void f(); } }" - "namespace NS1 { namespace { void f(); } }", - Lang_CXX, "input0.cc"); + TranslationUnitDecl *FromTu = + getTuDecl("namespace NS0 { namespace { void f(); } }" + "namespace NS1 { namespace { void f(); } }", + Lang_CXX03, "input0.cc"); auto Pattern = functionDecl(hasName("f")); auto *FromF0 = FirstDeclMatcher().match(FromTu, Pattern); auto *FromF1 = LastDeclMatcher().match(FromTu, Pattern); - auto *ToF0 = Import(FromF0, Lang_CXX); - auto *ToF1 = Import(FromF1, Lang_CXX); + auto *ToF0 = Import(FromF0, Lang_CXX03); + auto *ToF1 = Import(FromF1, Lang_CXX03); EXPECT_TRUE(ToF0); ASSERT_TRUE(ToF1); @@ -2341,19 +2288,19 @@ TEST_P(ImportFunctions, ImportFunctionFromUnnamedNamespace) { { Decl *FromTU = getTuDecl("namespace { void f() {} } void g0() { f(); }", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("g0"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } { Decl *FromTU = getTuDecl("namespace { void f() { int a; } } void g1() { f(); }", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("g1"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2371,7 +2318,7 @@ Lang_CXX11); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("foo"))); - auto *ToD = Import(FromD, Lang_CXX); + auto *ToD = Import(FromD, Lang_CXX03); EXPECT_TRUE(ToD); CXXRecordDecl *LambdaRec = cast(cast( @@ -2394,10 +2341,10 @@ x.foo(); } )", - Lang_CXX); + Lang_CXX03); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); - auto *ToD = Import(FromD, Lang_CXX); + auto *ToD = Import(FromD, Lang_CXX03); EXPECT_TRUE(ToD); EXPECT_TRUE(MatchVerifier().match( ToD, functionDecl(hasName("f"), hasDescendant(declRefExpr())))); @@ -2420,10 +2367,10 @@ f(); } )", - Lang_CXX); + Lang_CXX03); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("g"))); - auto *ToD = Import(FromD, Lang_CXX); + auto *ToD = Import(FromD, Lang_CXX03); EXPECT_TRUE(ToD); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); EXPECT_TRUE(MatchVerifier().match( @@ -2441,14 +2388,14 @@ void f(T t); }; )"; - Decl *FromTU1 = getTuDecl(Code, Lang_CXX, "input1.cc"); + Decl *FromTU1 = getTuDecl(Code, Lang_CXX03, "input1.cc"); auto *FromD1 = FirstDeclMatcher().match( FromTU1, functionTemplateDecl(hasName("f"))); - auto *ToD1 = Import(FromD1, Lang_CXX); - Decl *FromTU2 = getTuDecl(Code, Lang_CXX, "input2.cc"); + auto *ToD1 = Import(FromD1, Lang_CXX03); + Decl *FromTU2 = getTuDecl(Code, Lang_CXX03, "input2.cc"); auto *FromD2 = FirstDeclMatcher().match( FromTU2, functionTemplateDecl(hasName("f"))); - auto *ToD2 = Import(FromD2, Lang_CXX); + auto *ToD2 = Import(FromD2, Lang_CXX03); EXPECT_EQ(ToD1, ToD2); } @@ -2463,14 +2410,14 @@ template void X::f(T t) {}; )"; - Decl *FromTU1 = getTuDecl(Code, Lang_CXX, "input1.cc"); + Decl *FromTU1 = getTuDecl(Code, Lang_CXX03, "input1.cc"); auto *FromD1 = FirstDeclMatcher().match( FromTU1, functionTemplateDecl(hasName("f"))); - auto *ToD1 = Import(FromD1, Lang_CXX); - Decl *FromTU2 = getTuDecl(Code, Lang_CXX, "input2.cc"); + auto *ToD1 = Import(FromD1, Lang_CXX03); + Decl *FromTU2 = getTuDecl(Code, Lang_CXX03, "input2.cc"); auto *FromD2 = FirstDeclMatcher().match( FromTU2, functionTemplateDecl(hasName("f"))); - auto *ToD2 = Import(FromD2, Lang_CXX); + auto *ToD2 = Import(FromD2, Lang_CXX03); EXPECT_EQ(ToD1, ToD2); } @@ -2482,11 +2429,11 @@ void foo(T) {} void foo(); )", - Lang_CXX); - Decl *FromTU = getTuDecl("void foo();", Lang_CXX); + Lang_CXX03); + Decl *FromTU = getTuDecl("void foo();", Lang_CXX03); auto *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("foo"))); - auto *ImportedD = Import(FromD, Lang_CXX); + auto *ImportedD = Import(FromD, Lang_CXX03); EXPECT_TRUE(ImportedD); } @@ -2500,11 +2447,11 @@ Foo(); }; )"; - getToTuDecl(Code, Lang_CXX); - Decl *FromTU = getTuDecl(Code, Lang_CXX); + getToTuDecl(Code, Lang_CXX03); + Decl *FromTU = getTuDecl(Code, Lang_CXX03); auto *FromD = LastDeclMatcher().match(FromTU, cxxConstructorDecl()); - auto *ImportedD = Import(FromD, Lang_CXX); + auto *ImportedD = Import(FromD, Lang_CXX03); EXPECT_TRUE(ImportedD); } @@ -2517,16 +2464,16 @@ struct X{}; void operator<(X, X); )", - Lang_CXX); + Lang_CXX03); Decl *FromTU = getTuDecl( R"( struct X{}; void operator<(X, X); )", - Lang_CXX); + Lang_CXX03); auto *FromD = LastDeclMatcher().match( FromTU, functionDecl(hasOverloadedOperatorName("<"))); - auto *ImportedD = Import(FromD, Lang_CXX); + auto *ImportedD = Import(FromD, Lang_CXX03); EXPECT_TRUE(ImportedD); } @@ -2537,11 +2484,10 @@ Decl *FromTU = getTuDecl("struct X { friend void f(); };" "void f();", - Lang_CXX, - "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - auto *ImportedD = cast(Import(FromD, Lang_CXX)); + auto *ImportedD = cast(Import(FromD, Lang_CXX03)); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u); EXPECT_FALSE(ImportedD->doesThisDeclarationHaveABody()); @@ -2556,10 +2502,10 @@ Decl *FromTU = getTuDecl("void f();" "struct X { friend void f(); };", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto FromD = FirstDeclMatcher().match(FromTU, Pattern); - auto *ImportedD = cast(Import(FromD, Lang_CXX)); + auto *ImportedD = cast(Import(FromD, Lang_CXX03)); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u); EXPECT_FALSE(ImportedD->doesThisDeclarationHaveABody()); @@ -2573,11 +2519,10 @@ Decl *FromTU = getTuDecl("struct X { friend void f(){} };" "void f();", - Lang_CXX, - "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - auto *ImportedD = cast(Import(FromD, Lang_CXX)); + auto *ImportedD = cast(Import(FromD, Lang_CXX03)); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u); EXPECT_TRUE(ImportedD->doesThisDeclarationHaveABody()); @@ -2592,10 +2537,10 @@ Decl *FromTU = getTuDecl("struct X { friend void f(); };" "void f(){}", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - auto *ImportedD = cast(Import(FromD, Lang_CXX)); + auto *ImportedD = cast(Import(FromD, Lang_CXX03)); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u); EXPECT_FALSE(ImportedD->doesThisDeclarationHaveABody()); @@ -2615,10 +2560,10 @@ friend void f(X *x); }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - auto *ImportedD = cast(Import(FromD, Lang_CXX)); + auto *ImportedD = cast(Import(FromD, Lang_CXX03)); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u); EXPECT_TRUE(ImportedD->doesThisDeclarationHaveABody()); @@ -2644,10 +2589,10 @@ friend void f(X *x); }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = LastDeclMatcher().match(FromTU, Pattern); - auto *ImportedD = cast(Import(FromD, Lang_CXX)); + auto *ImportedD = cast(Import(FromD, Lang_CXX03)); Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); ASSERT_EQ(DeclCounter().match(ToTU, Pattern), 2u); EXPECT_FALSE(ImportedD->doesThisDeclarationHaveABody()); @@ -2667,15 +2612,15 @@ FunctionDecl *ImportedD; { Decl *FromTU = - getTuDecl("struct X { friend void f(){} };", Lang_CXX, "input0.cc"); + getTuDecl("struct X { friend void f(){} };", Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - ImportedD = cast(Import(FromD, Lang_CXX)); + ImportedD = cast(Import(FromD, Lang_CXX03)); } FunctionDecl *ImportedD1; { - Decl *FromTU = getTuDecl("void f();", Lang_CXX, "input1.cc"); + Decl *FromTU = getTuDecl("void f();", Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - ImportedD1 = cast(Import(FromD, Lang_CXX)); + ImportedD1 = cast(Import(FromD, Lang_CXX03)); } Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2690,7 +2635,7 @@ auto ClassPattern = cxxRecordDecl(hasName("X")); TranslationUnitDecl *FromTU = - getTuDecl("struct X { friend void f(); };", Lang_CXX, "input0.cc"); + getTuDecl("struct X { friend void f(); };", Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match(FromTU, FunctionPattern); ASSERT_TRUE(FromD->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend)); ASSERT_FALSE(FromD->isInIdentifierNamespace(Decl::IDNS_Ordinary)); @@ -2703,7 +2648,7 @@ ASSERT_EQ(LookupRes.size(), 1u); } - auto *ToD = cast(Import(FromD, Lang_CXX)); + auto *ToD = cast(Import(FromD, Lang_CXX03)); auto ToName = ToD->getDeclName(); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2723,15 +2668,15 @@ auto FunctionPattern = functionDecl(hasName("f")); auto ClassPattern = cxxRecordDecl(hasName("X")); - TranslationUnitDecl *FromTU = getTuDecl( - "struct X { friend void f(); };" - // This proto decl makes f available to normal - // lookup, otherwise it is hidden. - // Normal C++ lookup (implemented in - // `clang::Sema::CppLookupName()` and in `LookupDirect()`) - // returns the found `NamedDecl` only if the set IDNS is matched - "void f();", - Lang_CXX, "input0.cc"); + TranslationUnitDecl *FromTU = + getTuDecl("struct X { friend void f(); };" + // This proto decl makes f available to normal + // lookup, otherwise it is hidden. + // Normal C++ lookup (implemented in + // `clang::Sema::CppLookupName()` and in `LookupDirect()`) + // returns the found `NamedDecl` only if the set IDNS is matched + "void f();", + Lang_CXX03, "input0.cc"); auto *FromFriend = FirstDeclMatcher().match(FromTU, FunctionPattern); auto *FromNormal = @@ -2749,7 +2694,7 @@ LookupRes = FromTU->noload_lookup(FromName); ASSERT_EQ(LookupRes.size(), 1u); - auto *ToFriend = cast(Import(FromFriend, Lang_CXX)); + auto *ToFriend = cast(Import(FromFriend, Lang_CXX03)); auto ToName = ToFriend->getDeclName(); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2773,10 +2718,9 @@ auto FunctionPattern = functionDecl(hasName("f")); auto ClassPattern = cxxRecordDecl(hasName("X")); - TranslationUnitDecl *FromTU = getTuDecl( - "void f();" - "struct X { friend void f(); };", - Lang_CXX, "input0.cc"); + TranslationUnitDecl *FromTU = getTuDecl("void f();" + "struct X { friend void f(); };", + Lang_CXX03, "input0.cc"); auto *FromNormal = FirstDeclMatcher().match(FromTU, FunctionPattern); auto *FromFriend = @@ -2794,7 +2738,7 @@ LookupRes = FromTU->noload_lookup(FromName); ASSERT_EQ(LookupRes.size(), 1u); - auto *ToNormal = cast(Import(FromNormal, Lang_CXX)); + auto *ToNormal = cast(Import(FromNormal, Lang_CXX03)); auto ToName = ToNormal->getDeclName(); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -2817,11 +2761,11 @@ auto Pattern = functionDecl(hasName("f")); TranslationUnitDecl *FromNormalTU = - getTuDecl("void f();", Lang_CXX, "input0.cc"); + getTuDecl("void f();", Lang_CXX03, "input0.cc"); auto *FromNormalF = FirstDeclMatcher().match(FromNormalTU, Pattern); TranslationUnitDecl *FromFriendTU = - getTuDecl("class X { friend void f(); };", Lang_CXX, "input1.cc"); + getTuDecl("class X { friend void f(); };", Lang_CXX03, "input1.cc"); auto *FromFriendF = FirstDeclMatcher().match(FromFriendTU, Pattern); auto FromNormalName = FromNormalF->getDeclName(); @@ -2836,7 +2780,7 @@ LookupRes = FromFriendTU->noload_lookup(FromFriendName); ASSERT_EQ(LookupRes.size(), 1u); - auto *ToNormalF = cast(Import(FromNormalF, Lang_CXX)); + auto *ToNormalF = cast(Import(FromNormalF, Lang_CXX03)); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); auto ToName = ToNormalF->getDeclName(); EXPECT_TRUE(ToNormalF->isInIdentifierNamespace(Decl::IDNS_Ordinary)); @@ -2845,7 +2789,7 @@ EXPECT_EQ(LookupRes.size(), 1u); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 1u); - auto *ToFriendF = cast(Import(FromFriendF, Lang_CXX)); + auto *ToFriendF = cast(Import(FromFriendF, Lang_CXX03)); LookupRes = ToTU->noload_lookup(ToName); EXPECT_EQ(LookupRes.size(), 1u); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u); @@ -2858,10 +2802,9 @@ } TEST_P(ImportFriendFunctions, ImportFriendList) { - TranslationUnitDecl *FromTU = getTuDecl( - "struct X { friend void f(); };" - "void f();", - Lang_CXX, "input0.cc"); + TranslationUnitDecl *FromTU = getTuDecl("struct X { friend void f(); };" + "void f();", + Lang_CXX03, "input0.cc"); auto *FromFriendF = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); @@ -2876,7 +2819,7 @@ } ASSERT_EQ(FrN, 1u); - Import(FromFriendF, Lang_CXX); + Import(FromFriendF, Lang_CXX03); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); auto *ToClass = FirstDeclMatcher().match( ToTU, cxxRecordDecl(hasName("X"))); @@ -2902,20 +2845,20 @@ {"void foo();" "void moo();" "int main() { foo(); moo(); }", - Lang_C}}, + Lang_C99}}, {"foo.c", {"typedef enum { THING_VALUE } thing_t;" "void conflict(thing_t type);" "void foo() { (void)THING_VALUE; }" "void conflict(thing_t type) {}", - Lang_C}}, + Lang_C99}}, {"moo.c", {"typedef enum { THING_VALUE } thing_t;" "void conflict(thing_t type);" "void moo() { conflict(THING_VALUE); }", - Lang_C}}}; + Lang_C99}}}; auto VerificationMatcher = enumDecl(has(enumConstantDecl(hasName("THING_VALUE"))), @@ -3114,22 +3057,20 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfEquivalentRecord) { Decl *ToR1; { - Decl *FromTU = getTuDecl( - "struct A { };", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("struct A { };", Lang_CXX03, "input0.cc"); auto *FromR = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("A"))); - ToR1 = Import(FromR, Lang_CXX); + ToR1 = Import(FromR, Lang_CXX03); } Decl *ToR2; { - Decl *FromTU = getTuDecl( - "struct A { };", Lang_CXX, "input1.cc"); + Decl *FromTU = getTuDecl("struct A { };", Lang_CXX03, "input1.cc"); auto *FromR = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("A"))); - ToR2 = Import(FromR, Lang_CXX); + ToR2 = Import(FromR, Lang_CXX03); } EXPECT_EQ(ToR1, ToR2); @@ -3138,19 +3079,18 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentRecord) { Decl *ToR1; { - Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("struct A { int x; };", Lang_CXX03, "input0.cc"); auto *FromR = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("A"))); - ToR1 = Import(FromR, Lang_CXX); + ToR1 = Import(FromR, Lang_CXX03); } Decl *ToR2; { - Decl *FromTU = getTuDecl( - "struct A { unsigned x; };", Lang_CXX, "input1.cc"); + Decl *FromTU = + getTuDecl("struct A { unsigned x; };", Lang_CXX03, "input1.cc"); auto *FromR = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("A"))); - ToR2 = Import(FromR, Lang_CXX); + ToR2 = Import(FromR, Lang_CXX03); } EXPECT_NE(ToR1, ToR2); } @@ -3158,19 +3098,17 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfEquivalentField) { Decl *ToF1; { - Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("struct A { int x; };", Lang_CXX03, "input0.cc"); auto *FromF = FirstDeclMatcher().match( FromTU, fieldDecl(hasName("x"))); - ToF1 = Import(FromF, Lang_CXX); + ToF1 = Import(FromF, Lang_CXX03); } Decl *ToF2; { - Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input1.cc"); + Decl *FromTU = getTuDecl("struct A { int x; };", Lang_CXX03, "input1.cc"); auto *FromF = FirstDeclMatcher().match( FromTU, fieldDecl(hasName("x"))); - ToF2 = Import(FromF, Lang_CXX); + ToF2 = Import(FromF, Lang_CXX03); } EXPECT_EQ(ToF1, ToF2); } @@ -3178,19 +3116,18 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentField) { Decl *ToF1; { - Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("struct A { int x; };", Lang_CXX03, "input0.cc"); auto *FromF = FirstDeclMatcher().match( FromTU, fieldDecl(hasName("x"))); - ToF1 = Import(FromF, Lang_CXX); + ToF1 = Import(FromF, Lang_CXX03); } Decl *ToF2; { - Decl *FromTU = getTuDecl( - "struct A { unsigned x; };", Lang_CXX, "input1.cc"); + Decl *FromTU = + getTuDecl("struct A { unsigned x; };", Lang_CXX03, "input1.cc"); auto *FromF = FirstDeclMatcher().match( FromTU, fieldDecl(hasName("x"))); - ToF2 = Import(FromF, Lang_CXX); + ToF2 = Import(FromF, Lang_CXX03); } EXPECT_NE(ToF1, ToF2); } @@ -3198,19 +3135,19 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfEquivalentMethod) { Decl *ToM1; { - Decl *FromTU = getTuDecl( - "struct A { void x(); }; void A::x() { }", Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("struct A { void x(); }; void A::x() { }", + Lang_CXX03, "input0.cc"); auto *FromM = FirstDeclMatcher().match( FromTU, functionDecl(hasName("x"), isDefinition())); - ToM1 = Import(FromM, Lang_CXX); + ToM1 = Import(FromM, Lang_CXX03); } Decl *ToM2; { - Decl *FromTU = getTuDecl( - "struct A { void x(); }; void A::x() { }", Lang_CXX, "input1.cc"); + Decl *FromTU = getTuDecl("struct A { void x(); }; void A::x() { }", + Lang_CXX03, "input1.cc"); auto *FromM = FirstDeclMatcher().match( FromTU, functionDecl(hasName("x"), isDefinition())); - ToM2 = Import(FromM, Lang_CXX); + ToM2 = Import(FromM, Lang_CXX03); } EXPECT_EQ(ToM1, ToM2); } @@ -3218,21 +3155,20 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportOfNonEquivalentMethod) { Decl *ToM1; { - Decl *FromTU = getTuDecl( - "struct A { void x(); }; void A::x() { }", - Lang_CXX, "input0.cc"); + Decl *FromTU = getTuDecl("struct A { void x(); }; void A::x() { }", + Lang_CXX03, "input0.cc"); auto *FromM = FirstDeclMatcher().match( FromTU, functionDecl(hasName("x"), isDefinition())); - ToM1 = Import(FromM, Lang_CXX); + ToM1 = Import(FromM, Lang_CXX03); } Decl *ToM2; { - Decl *FromTU = getTuDecl( - "struct A { void x() const; }; void A::x() const { }", - Lang_CXX, "input1.cc"); + Decl *FromTU = + getTuDecl("struct A { void x() const; }; void A::x() const { }", + Lang_CXX03, "input1.cc"); auto *FromM = FirstDeclMatcher().match( FromTU, functionDecl(hasName("x"), isDefinition())); - ToM2 = Import(FromM, Lang_CXX); + ToM2 = Import(FromM, Lang_CXX03); } EXPECT_NE(ToM1, ToM2); } @@ -3250,11 +3186,11 @@ } entry1; }; )", - Lang_C, "input0.cc"); + Lang_C99, "input0.cc"); auto *From = FirstDeclMatcher().match(FromTU, recordDecl(hasName("A"))); - Import(From, Lang_C); + Import(From, Lang_C99); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); auto *Entry0 = @@ -3594,7 +3530,8 @@ static const int a = 1 + 2; }; const int A::a; - )", Lang_CXX, "input1.cc"); + )", + Lang_CXX03, "input1.cc"); auto *FromDWithInit = FirstDeclMatcher().match( FromTU, varDecl(hasName("a"))); // Decl with init @@ -3618,8 +3555,8 @@ static const int a = 1 + 2; }; )"; - Decl *ToTU = getToTuDecl(StructA, Lang_CXX); - Decl *FromTU = getTuDecl(std::string(StructA) + "const int A::a;", Lang_CXX, + Decl *ToTU = getToTuDecl(StructA, Lang_CXX03); + Decl *FromTU = getTuDecl(std::string(StructA) + "const int A::a;", Lang_CXX03, "input1.cc"); auto *FromDWithInit = FirstDeclMatcher().match( @@ -3649,9 +3586,9 @@ static const int a; }; )"; - Decl *ToTU = getToTuDecl(StructA, Lang_CXX); + Decl *ToTU = getToTuDecl(StructA, Lang_CXX03); Decl *FromTU = getTuDecl(std::string(StructA) + "const int A::a = 1 + 2;", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *FromDDeclarationOnly = FirstDeclMatcher().match( FromTU, varDecl(hasName("a"))); @@ -3676,13 +3613,13 @@ struct ImportClasses : ASTImporterOptionSpecificTestBase {}; TEST_P(ImportClasses, ImportDefinitionWhenProtoIsInNestedToContext) { - Decl *ToTU = getToTuDecl("struct A { struct X *Xp; };", Lang_C); - Decl *FromTU1 = getTuDecl("struct X {};", Lang_C, "input1.cc"); + Decl *ToTU = getToTuDecl("struct A { struct X *Xp; };", Lang_C99); + Decl *FromTU1 = getTuDecl("struct X {};", Lang_C99, "input1.cc"); auto Pattern = recordDecl(hasName("X"), unless(isImplicit())); auto ToProto = FirstDeclMatcher().match(ToTU, Pattern); auto FromDef = FirstDeclMatcher().match(FromTU1, Pattern); - Decl *ImportedDef = Import(FromDef, Lang_C); + Decl *ImportedDef = Import(FromDef, Lang_C99); EXPECT_NE(ImportedDef, ToProto); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u); @@ -3694,13 +3631,13 @@ } TEST_P(ImportClasses, ImportDefinitionWhenProtoIsInNestedToContextCXX) { - Decl *ToTU = getToTuDecl("struct A { struct X *Xp; };", Lang_CXX); - Decl *FromTU1 = getTuDecl("struct X {};", Lang_CXX, "input1.cc"); + Decl *ToTU = getToTuDecl("struct A { struct X *Xp; };", Lang_CXX03); + Decl *FromTU1 = getTuDecl("struct X {};", Lang_CXX03, "input1.cc"); auto Pattern = recordDecl(hasName("X"), unless(isImplicit())); auto ToProto = FirstDeclMatcher().match(ToTU, Pattern); auto FromDef = FirstDeclMatcher().match(FromTU1, Pattern); - Decl *ImportedDef = Import(FromDef, Lang_CXX); + Decl *ImportedDef = Import(FromDef, Lang_CXX03); EXPECT_NE(ImportedDef, ToProto); EXPECT_EQ(DeclCounter().match(ToTU, Pattern), 2u); @@ -3712,14 +3649,15 @@ } TEST_P(ImportClasses, ImportNestedPrototypeThenDefinition) { - Decl *FromTU0 = getTuDecl("struct A { struct X *Xp; };", Lang_C, "input0.cc"); - Decl *FromTU1 = getTuDecl("struct X {};", Lang_C, "input1.cc"); + Decl *FromTU0 = + getTuDecl("struct A { struct X *Xp; };", Lang_C99, "input0.cc"); + Decl *FromTU1 = getTuDecl("struct X {};", Lang_C99, "input1.cc"); auto Pattern = recordDecl(hasName("X"), unless(isImplicit())); auto FromProto = FirstDeclMatcher().match(FromTU0, Pattern); auto FromDef = FirstDeclMatcher().match(FromTU1, Pattern); - Decl *ImportedProto = Import(FromProto, Lang_C); - Decl *ImportedDef = Import(FromDef, Lang_C); + Decl *ImportedProto = Import(FromProto, Lang_C99); + Decl *ImportedDef = Import(FromDef, Lang_C99); Decl *ToTU = ImportedDef->getTranslationUnitDecl(); EXPECT_NE(ImportedDef, ImportedProto); @@ -3746,7 +3684,7 @@ }; }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromClass = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("F"), isDefinition())); @@ -3761,8 +3699,9 @@ ASSERT_EQ(FromFriendClass->getDescribedClassTemplate()->getPreviousDecl(), FromClass->getDescribedClassTemplate()); - auto *ToClass = cast(Import(FromClass, Lang_CXX)); - auto *ToFriendClass = cast(Import(FromFriendClass, Lang_CXX)); + auto *ToClass = cast(Import(FromClass, Lang_CXX03)); + auto *ToFriendClass = + cast(Import(FromFriendClass, Lang_CXX03)); EXPECT_TRUE(ToClass); EXPECT_TRUE(ToFriendClass); @@ -3780,18 +3719,19 @@ friend class declToImport; }; )", - Lang_CXX, "input.cc"); + Lang_CXX03, "input.cc"); auto *FromD = FirstDeclMatcher().match( FromTu, cxxRecordDecl(hasName("declToImport"))); - auto *ToD = Import(FromD, Lang_CXX); + auto *ToD = Import(FromD, Lang_CXX03); auto Pattern = cxxRecordDecl(has(friendDecl())); ASSERT_TRUE(MatchVerifier{}.match(FromD, Pattern)); EXPECT_TRUE(MatchVerifier{}.match(ToD, Pattern)); } TEST_P(ImportFriendClasses, UndeclaredFriendClassShouldNotBeVisible) { - Decl *FromTu = getTuDecl("class X { friend class Y; };", Lang_CXX, "from.cc"); + Decl *FromTu = + getTuDecl("class X { friend class Y; };", Lang_CXX03, "from.cc"); auto *FromX = FirstDeclMatcher().match( FromTu, cxxRecordDecl(hasName("X"))); auto *FromFriend = FirstDeclMatcher().match(FromTu, friendDecl()); @@ -3809,7 +3749,7 @@ ->lookup(FromRecordOfFriend->getDeclName()) .empty()); - auto *ToX = Import(FromX, Lang_CXX); + auto *ToX = Import(FromX, Lang_CXX03); ASSERT_TRUE(ToX); Decl *ToTu = ToX->getTranslationUnitDecl(); @@ -3835,11 +3775,11 @@ template friend class declToImport; }; )", - Lang_CXX, "input.cc"); + Lang_CXX03, "input.cc"); auto *FromD = FirstDeclMatcher().match(FromTu, classTemplateDecl()); - auto *ToD = Import(FromD, Lang_CXX); + auto *ToD = Import(FromD, Lang_CXX03); auto Pattern = classTemplateDecl( has(cxxRecordDecl(has(friendDecl(has(classTemplateDecl())))))); @@ -3860,22 +3800,24 @@ { Decl *FromTU = getTuDecl("template class X;" "struct Y { friend class X; };", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, Pattern); - Imported1 = cast(Import(FromD, Lang_CXX)); + Imported1 = + cast(Import(FromD, Lang_CXX03)); } ClassTemplateSpecializationDecl *Imported2; { Decl *FromTU = getTuDecl("template class X;" "template<> class X{};" "struct Z { friend class X; };", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, Pattern); - Imported2 = cast(Import(FromD, Lang_CXX)); + Imported2 = + cast(Import(FromD, Lang_CXX03)); } Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -3896,19 +3838,19 @@ friend class F; // The decl context of F is the global namespace. }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *Fwd = FirstDeclMatcher().match( FromTU0, classTemplateDecl(hasName("F"))); - auto *Imported0 = cast(Import(Fwd, Lang_CXX)); + auto *Imported0 = cast(Import(Fwd, Lang_CXX03)); Decl *FromTU1 = getTuDecl( R"( template class F {}; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *Definition = FirstDeclMatcher().match( FromTU1, classTemplateDecl(hasName("F"))); - auto *Imported1 = cast(Import(Definition, Lang_CXX)); + auto *Imported1 = cast(Import(Definition, Lang_CXX03)); EXPECT_EQ(Imported0->getTemplatedDecl()->getTypeForDecl(), Imported1->getTemplatedDecl()->getTypeForDecl()); } @@ -3916,8 +3858,8 @@ TEST_P(ImportFriendClasses, DeclsFromFriendsShouldBeInRedeclChains) { Decl *From, *To; std::tie(From, To) = - getImportedDecl("class declToImport {};", Lang_CXX, - "class Y { friend class declToImport; };", Lang_CXX); + getImportedDecl("class declToImport {};", Lang_CXX03, + "class Y { friend class declToImport; };", Lang_CXX03); auto *Imported = cast(To); EXPECT_TRUE(Imported->getPreviousDecl()); @@ -3935,7 +3877,7 @@ friend class F; // The decl context of F is the global namespace. }; )", - Lang_CXX); + Lang_CXX03); auto *ToDecl = FirstDeclMatcher().match( ToTU, classTemplateDecl(hasName("F"))); Decl *FromTU = getTuDecl( @@ -3943,10 +3885,10 @@ template class F {}; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *Definition = FirstDeclMatcher().match( FromTU, classTemplateDecl(hasName("F"))); - auto *ImportedDef = cast(Import(Definition, Lang_CXX)); + auto *ImportedDef = cast(Import(Definition, Lang_CXX03)); EXPECT_TRUE(ImportedDef->getPreviousDecl()); EXPECT_EQ(ToDecl, ImportedDef->getPreviousDecl()); EXPECT_EQ(ToDecl->getTemplatedDecl(), @@ -3965,19 +3907,19 @@ friend class F; // The decl context of F is the global namespace. }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *Fwd = FirstDeclMatcher().match( FromTU0, classTemplateDecl(hasName("F"))); - auto *ImportedFwd = cast(Import(Fwd, Lang_CXX)); + auto *ImportedFwd = cast(Import(Fwd, Lang_CXX03)); Decl *FromTU1 = getTuDecl( R"( template class F {}; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *Definition = FirstDeclMatcher().match( FromTU1, classTemplateDecl(hasName("F"))); - auto *ImportedDef = cast(Import(Definition, Lang_CXX)); + auto *ImportedDef = cast(Import(Definition, Lang_CXX03)); EXPECT_TRUE(ImportedDef->getPreviousDecl()); EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl()); EXPECT_EQ(ImportedFwd->getTemplatedDecl(), @@ -3994,20 +3936,20 @@ friend class F; // The decl context of F is the global namespace. }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *Friend = FirstDeclMatcher().match(FromTU0, friendDecl()); QualType FT = Friend->getFriendType()->getType(); FT = FromTU0->getASTContext().getCanonicalType(FT); auto *Fwd = cast(FT)->getDecl(); - auto *ImportedFwd = Import(Fwd, Lang_CXX); + auto *ImportedFwd = Import(Fwd, Lang_CXX03); Decl *FromTU1 = getTuDecl( R"( class F {}; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *Definition = FirstDeclMatcher().match( FromTU1, cxxRecordDecl(hasName("F"))); - auto *ImportedDef = Import(Definition, Lang_CXX); + auto *ImportedDef = Import(Definition, Lang_CXX03); EXPECT_TRUE(ImportedDef->getPreviousDecl()); EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl()); } @@ -4019,14 +3961,14 @@ friend void foo(){} }; )"; - TranslationUnitDecl *ToTU = getToTuDecl(Code, Lang_CXX); + TranslationUnitDecl *ToTU = getToTuDecl(Code, Lang_CXX03); auto *ToFoo = FirstDeclMatcher().match( ToTU, functionDecl(hasName("foo"))); - TranslationUnitDecl *FromTU = getTuDecl(Code, Lang_CXX, "input.cc"); + TranslationUnitDecl *FromTU = getTuDecl(Code, Lang_CXX03, "input.cc"); auto *FromFoo = FirstDeclMatcher().match( FromTU, functionDecl(hasName("foo"))); - auto *ImportedFoo = Import(FromFoo, Lang_CXX); + auto *ImportedFoo = Import(FromFoo, Lang_CXX03); EXPECT_EQ(ImportedFoo, ToFoo); } @@ -4061,7 +4003,7 @@ TEST_P(DeclContextTest, removeDeclShouldNotFailEvenIfWeHaveExternalVisibleStorage) { - Decl *TU = getTuDecl("extern int A; int A;", Lang_CXX); + Decl *TU = getTuDecl("extern int A; int A;", Lang_CXX03); auto *A0 = FirstDeclMatcher().match(TU, varDecl(hasName("A"))); auto *A1 = LastDeclMatcher().match(TU, varDecl(hasName("A"))); @@ -4105,7 +4047,7 @@ int f() { return 0; } void foo() { f(); } )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); // Check that the function template instantiation is NOT the child of the TU. auto Pattern = translationUnitDecl( @@ -4114,7 +4056,7 @@ auto *Foo = FirstDeclMatcher().match( FromTU, functionDecl(hasName("foo"))); - ASSERT_TRUE(Import(Foo, Lang_CXX)); + ASSERT_TRUE(Import(Foo, Lang_CXX03)); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); EXPECT_TRUE(MatchVerifier{}.match(ToTU, Pattern)); @@ -4129,15 +4071,15 @@ int f() { return 0; } template int f(); )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); // Check that the function template instantiation is NOT the child of the TU. auto Instantiation = functionDecl(hasName("f"), isTemplateInstantiation()); auto Pattern = translationUnitDecl(unless(has(Instantiation))); ASSERT_TRUE(MatchVerifier{}.match(FromTU, Pattern)); - ASSERT_TRUE( - Import(FirstDeclMatcher().match(FromTU, Instantiation), Lang_CXX)); + ASSERT_TRUE(Import(FirstDeclMatcher().match(FromTU, Instantiation), + Lang_CXX03)); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); EXPECT_TRUE(MatchVerifier{}.match(ToTU, Pattern)); @@ -4152,7 +4094,7 @@ int f() { return 0; } template <> int f() { return 4; } )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); // Check that the function template specialization is the child of the TU. auto Specialization = @@ -4160,8 +4102,8 @@ auto Pattern = translationUnitDecl(has(Specialization)); ASSERT_TRUE(MatchVerifier{}.match(FromTU, Pattern)); - ASSERT_TRUE( - Import(FirstDeclMatcher().match(FromTU, Specialization), Lang_CXX)); + ASSERT_TRUE(Import(FirstDeclMatcher().match(FromTU, Specialization), + Lang_CXX03)); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); EXPECT_TRUE(MatchVerifier{}.match(ToTU, Pattern)); @@ -4176,7 +4118,7 @@ int f() { return 0; } template <> int f() { return 4; } )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto Spec = functionDecl(hasName("f"), isExplicitTemplateSpecialization(), hasParent(translationUnitDecl())); @@ -4193,7 +4135,7 @@ ->doesThisDeclarationHaveABody()); } - ASSERT_TRUE(Import(FromSpecD, Lang_CXX)); + ASSERT_TRUE(Import(FromSpecD, Lang_CXX03)); { auto *TU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -4239,11 +4181,11 @@ template struct B; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromD = FirstDeclMatcher().match( FromTU, classTemplateDecl(hasName("B"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); } { @@ -4255,13 +4197,13 @@ B* b; }; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); FunctionDecl *FromD = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); - Import(FromD, Lang_CXX); + Import(FromD, Lang_CXX03); auto *FromCTD = FirstDeclMatcher().match( FromTU, classTemplateDecl(hasName("B"))); - auto *ToCTD = cast(Import(FromCTD, Lang_CXX)); + auto *ToCTD = cast(Import(FromCTD, Lang_CXX03)); EXPECT_TRUE(ToCTD->isThisDeclarationADefinition()); // We expect no (ODR) warning during the import. @@ -4311,12 +4253,12 @@ template <> int f() { return 4; } )"; - Decl *FromTU = getTuDecl(Code, Lang_CXX); + Decl *FromTU = getTuDecl(Code, Lang_CXX03); auto *FromD = FirstDeclMatcher().match(FromTU, functionDecl(hasName("f"), isExplicitTemplateSpecialization())); ASSERT_EQ(FromD->getNumTemplateParameterLists(), 1u); - auto *ToD = Import(FromD, Lang_CXX); + auto *ToD = Import(FromD, Lang_CXX03); // The template parameter list should exist. EXPECT_EQ(ToD->getNumTemplateParameterLists(), 1u); } @@ -4324,7 +4266,7 @@ struct ASTImporterLookupTableTest : ASTImporterOptionSpecificTestBase {}; TEST_P(ASTImporterLookupTableTest, OneDecl) { - auto *ToTU = getToTuDecl("int a;", Lang_CXX); + auto *ToTU = getToTuDecl("int a;", Lang_CXX03); auto *D = FirstDeclMatcher().match(ToTU, varDecl(hasName("a"))); ASTImporterLookupTable LT(*ToTU); auto Res = LT.lookup(ToTU, D->getDeclName()); @@ -4349,7 +4291,7 @@ friend void foo(){} }; )"; - TranslationUnitDecl *ToTU = getToTuDecl(Code, Lang_CXX); + TranslationUnitDecl *ToTU = getToTuDecl(Code, Lang_CXX03); auto *X = FirstDeclMatcher().match( ToTU, classTemplateDecl(hasName("X"))); auto *Foo = FirstDeclMatcher().match( @@ -4385,7 +4327,7 @@ TEST_P(ASTImporterLookupTableTest, FwdDeclStructShouldBeFoundByImporterSpecificLookup) { TranslationUnitDecl *ToTU = - getToTuDecl("struct A { struct Foo *p; };", Lang_C); + getToTuDecl("struct A { struct Foo *p; };", Lang_C99); auto *Foo = FirstDeclMatcher().match(ToTU, recordDecl(hasName("Foo"))); auto *A = @@ -4420,7 +4362,7 @@ TEST_P(ASTImporterLookupTableTest, LookupFindsNamesInDifferentDC) { TranslationUnitDecl *ToTU = - getToTuDecl("int V; struct A { int V; }; struct B { int V; };", Lang_C); + getToTuDecl("int V; struct A { int V; }; struct B { int V; };", Lang_C99); DeclarationName VName = FirstDeclMatcher() .match(ToTU, varDecl(hasName("V"))) ->getDeclName(); @@ -4455,7 +4397,7 @@ void foo(int); void foo(int, int); )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F0 = FirstDeclMatcher().match(ToTU, functionDecl()); @@ -4475,7 +4417,7 @@ void operator+(X, X); void operator-(X, X); )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *FPlus = FirstDeclMatcher().match( @@ -4501,7 +4443,7 @@ struct X {}; void operator+(X, X); )", - Lang_CXX); + Lang_CXX03); auto *ToPlus = FirstDeclMatcher().match( ToTU, functionDecl(hasOverloadedOperatorName("+"))); @@ -4510,7 +4452,7 @@ struct X {}; void operator+(X, X); )", - Lang_CXX); + Lang_CXX03); auto *FromPlus = FirstDeclMatcher().match( FromTU, functionDecl(hasOverloadedOperatorName("+"))); @@ -4533,7 +4475,7 @@ R"( class Y { friend class F; }; )", - Lang_CXX); + Lang_CXX03); // In this case, the CXXRecordDecl is hidden, the FriendDecl is not a parent. // So we must dig up the underlying CXXRecordDecl. @@ -4603,7 +4545,7 @@ R"( class Y { template friend class F; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4626,7 +4568,7 @@ friend class F; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4648,7 +4590,7 @@ friend class F; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4666,7 +4608,7 @@ R"( class Y { friend void F(); }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = @@ -4689,7 +4631,7 @@ X xc; } )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); @@ -4731,7 +4673,7 @@ R"( class Y { template friend void F(); }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4754,7 +4696,7 @@ friend struct X; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *X = FirstDeclMatcher().match( @@ -4780,7 +4722,7 @@ B }; )", - Lang_C); + Lang_C99); ASTImporterLookupTable LT(*ToTU); auto *E = FirstDeclMatcher().match(ToTU, enumDecl(hasName("E"))); @@ -4820,7 +4762,7 @@ namespace N { } )", - Lang_CXX); + Lang_CXX03); auto *N1 = LastDeclMatcher().match(ToTU, namespaceDecl(hasName("N"))); auto *A = FirstDeclMatcher().match(ToTU, varDecl(hasName("A"))); @@ -4849,7 +4791,7 @@ }; } )", - Lang_CXX); + Lang_CXX03); auto *FromFwd = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("X"), unless(isImplicit()))); auto *FromDef = LastDeclMatcher().match( @@ -4860,8 +4802,8 @@ ASSERT_TRUE(FromDef->isThisDeclarationADefinition()); ASSERT_EQ(FromFwd->getCanonicalDecl(), FromDef->getCanonicalDecl()); - auto *ToDef = cast_or_null(Import(FromDef, Lang_CXX)); - auto *ToFwd = cast_or_null(Import(FromFwd, Lang_CXX)); + auto *ToDef = cast_or_null(Import(FromDef, Lang_CXX03)); + auto *ToFwd = cast_or_null(Import(FromFwd, Lang_CXX03)); EXPECT_NE(ToFwd, ToDef); EXPECT_FALSE(ToFwd->isThisDeclarationADefinition()); EXPECT_TRUE(ToDef->isThisDeclarationADefinition()); @@ -4880,7 +4822,7 @@ template friend void foo(); }; )", - Lang_CXX); + Lang_CXX03); auto *Friend = FirstDeclMatcher().match( ToTU, functionTemplateDecl(hasName("foo"))); @@ -4888,10 +4830,10 @@ R"( template void foo(); )", - Lang_CXX); + Lang_CXX03); auto *FromFoo = FirstDeclMatcher().match( FromTU, functionTemplateDecl(hasName("foo"))); - auto *Imported = Import(FromFoo, Lang_CXX); + auto *Imported = Import(FromFoo, Lang_CXX03); EXPECT_EQ(Imported->getPreviousDecl(), Friend); } @@ -4927,7 +4869,7 @@ template <> class X { int a; }; )", - Lang_CXX); + Lang_CXX03); TranslationUnitDecl *FromTU = getTuDecl( R"( template @@ -4935,10 +4877,10 @@ template <> class X { double b; }; )", - Lang_CXX); + Lang_CXX03); auto *FromSpec = FirstDeclMatcher().match( FromTU, classTemplateSpecializationDecl(hasName("X"))); - ClassTemplateSpecializationDecl *ImportedSpec = Import(FromSpec, Lang_CXX); + ClassTemplateSpecializationDecl *ImportedSpec = Import(FromSpec, Lang_CXX03); EXPECT_FALSE(ImportedSpec); // The original Decl is kept, no new decl is created. @@ -4958,12 +4900,11 @@ TEST_P(ErrorHandlingTest, ErrorHappensAfterCreatingTheNodeButBeforeLinkingThatToTheAST) { TranslationUnitDecl *FromTU = getTuDecl( - std::string("void foo() { ") + ErroneousStmt + " }", - Lang_CXX); + std::string("void foo() { ") + ErroneousStmt + " }", Lang_CXX03); auto *FromFoo = FirstDeclMatcher().match( FromTU, functionDecl(hasName("foo"))); - FunctionDecl *ImportedFoo = Import(FromFoo, Lang_CXX); + FunctionDecl *ImportedFoo = Import(FromFoo, Lang_CXX03); EXPECT_FALSE(ImportedFoo); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -4982,17 +4923,16 @@ // encountering the error. The error is set for the counterpart of the nodes in // the "from" context. TEST_P(ErrorHandlingTest, ErrorHappensAfterNodeIsCreatedAndLinked) { - TranslationUnitDecl *FromTU = getTuDecl( - std::string(R"( + TranslationUnitDecl *FromTU = getTuDecl(std::string(R"( void f(); void f() { )") + ErroneousStmt + R"( } )", - Lang_CXX); + Lang_CXX03); auto *FromProto = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); auto *FromDef = LastDeclMatcher().match(FromTU, functionDecl(hasName("f"))); - FunctionDecl *ImportedProto = Import(FromProto, Lang_CXX); + FunctionDecl *ImportedProto = Import(FromProto, Lang_CXX03); EXPECT_FALSE(ImportedProto); // Could not import. // However, we created two nodes in the AST. 1) the fwd decl 2) the // definition. The definition is not added to its DC, but the fwd decl is @@ -5017,18 +4957,17 @@ // An error should be set for a class if we cannot import one member. TEST_P(ErrorHandlingTest, ErrorIsPropagatedFromMemberToClass) { - TranslationUnitDecl *FromTU = getTuDecl( - std::string(R"( + TranslationUnitDecl *FromTU = getTuDecl(std::string(R"( class X { void f() { )") + ErroneousStmt + R"( } // This member has the error // during import. void ok(); // The error should not prevent importing this. }; // An error will be set for X too. )", - Lang_CXX); + Lang_CXX03); auto *FromX = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("X"))); - CXXRecordDecl *ImportedX = Import(FromX, Lang_CXX); + CXXRecordDecl *ImportedX = Import(FromX, Lang_CXX03); // An error is set for X. EXPECT_FALSE(ImportedX); @@ -5044,7 +4983,7 @@ ASSERT_TRUE(OptErr); EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct); // And any subsequent import should fail. - CXXMethodDecl *ImportedF = Import(FromF, Lang_CXX); + CXXMethodDecl *ImportedF = Import(FromF, Lang_CXX03); EXPECT_FALSE(ImportedF); // There is an error set for the other member too. @@ -5053,7 +4992,7 @@ OptErr = Importer->getImportDeclErrorIfAny(FromOK); EXPECT_TRUE(OptErr); // Cannot import the other member. - CXXMethodDecl *ImportedOK = Import(FromOK, Lang_CXX); + CXXMethodDecl *ImportedOK = Import(FromOK, Lang_CXX03); EXPECT_FALSE(ImportedOK); } @@ -5063,21 +5002,21 @@ // And to all AST nodes which we visit during the import process which finally // ends up in a failure (in the error() function). TEST_P(ErrorHandlingTest, ErrorPropagatesThroughImportCycles) { - Decl *FromTU = getTuDecl( - std::string(R"( + Decl *FromTU = getTuDecl(std::string(R"( namespace NS { class A { template class F {}; class X { template friend class F; - void error() { )") + ErroneousStmt + R"( } + void error() { )") + + ErroneousStmt + R"( } }; }; class B {}; } // NS )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromFRD = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("F"), isDefinition())); @@ -5090,13 +5029,13 @@ // Start by importing the templated CXXRecordDecl of F. // Import fails for that. - EXPECT_FALSE(Import(FromFRD, Lang_CXX)); + EXPECT_FALSE(Import(FromFRD, Lang_CXX03)); // Import fails for A. - EXPECT_FALSE(Import(FromA, Lang_CXX)); + EXPECT_FALSE(Import(FromA, Lang_CXX03)); // But we should be able to import the independent B. - EXPECT_TRUE(Import(FromB, Lang_CXX)); + EXPECT_TRUE(Import(FromB, Lang_CXX03)); // And the namespace. - EXPECT_TRUE(Import(FromNS, Lang_CXX)); + EXPECT_TRUE(Import(FromNS, Lang_CXX03)); // An error is set to the templated CXXRecordDecl of F. ASTImporter *Importer = findFromTU(FromFRD)->Importer.get(); @@ -5143,18 +5082,17 @@ } TEST_P(ErrorHandlingTest, ErrorIsNotPropagatedFromMemberToNamespace) { - TranslationUnitDecl *FromTU = getTuDecl( - std::string(R"( + TranslationUnitDecl *FromTU = getTuDecl(std::string(R"( namespace X { void f() { )") + ErroneousStmt + R"( } // This member has the error // during import. void ok(); // The error should not prevent importing this. }; // An error will be set for X too. )", - Lang_CXX); + Lang_CXX03); auto *FromX = FirstDeclMatcher().match( FromTU, namespaceDecl(hasName("X"))); - NamespaceDecl *ImportedX = Import(FromX, Lang_CXX); + NamespaceDecl *ImportedX = Import(FromX, Lang_CXX03); // There is no error set for X. EXPECT_TRUE(ImportedX); @@ -5169,7 +5107,7 @@ ASSERT_TRUE(OptErr); EXPECT_EQ(OptErr->Error, ImportError::UnsupportedConstruct); // And any subsequent import should fail. - FunctionDecl *ImportedF = Import(FromF, Lang_CXX); + FunctionDecl *ImportedF = Import(FromF, Lang_CXX03); EXPECT_FALSE(ImportedF); // There is no error set for ok(). @@ -5178,7 +5116,7 @@ OptErr = Importer->getImportDeclErrorIfAny(FromOK); EXPECT_FALSE(OptErr); // And we should be able to import. - FunctionDecl *ImportedOK = Import(FromOK, Lang_CXX); + FunctionDecl *ImportedOK = Import(FromOK, Lang_CXX03); EXPECT_TRUE(ImportedOK); } @@ -5187,8 +5125,7 @@ TEST_P(ErrorHandlingTest, ImportedDeclWithErrorShouldFailTheImportOfDeclWhichMapToIt) { // We already have a fwd decl. - TranslationUnitDecl *ToTU = getToTuDecl( - "class X;", Lang_CXX); + TranslationUnitDecl *ToTU = getToTuDecl("class X;", Lang_CXX03); // Then we import a definition. { TranslationUnitDecl *FromTU = getTuDecl(std::string(R"( @@ -5197,10 +5134,10 @@ void ok(); }; )", - Lang_CXX); + Lang_CXX03); auto *FromX = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("X"))); - CXXRecordDecl *ImportedX = Import(FromX, Lang_CXX); + CXXRecordDecl *ImportedX = Import(FromX, Lang_CXX03); // An error is set for X ... EXPECT_FALSE(ImportedX); @@ -5232,11 +5169,11 @@ void ok(); }; )", - Lang_CXX, "input1.cc"); + Lang_CXX03, "input1.cc"); auto *FromX = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("X"))); - CXXRecordDecl *ImportedX = Import(FromX, Lang_CXX); + CXXRecordDecl *ImportedX = Import(FromX, Lang_CXX03); // If we did not save the errors for the "to" context then the below checks // would fail, because the lookup finds the fwd Decl of the existing @@ -5367,8 +5304,8 @@ struct Class { }; )"; - TranslationUnitDecl *ToTU = getToTuDecl(Code, Lang_CXX); - TranslationUnitDecl *FromTU = getTuDecl(Code, Lang_CXX, "input.cc"); + TranslationUnitDecl *ToTU = getToTuDecl(Code, Lang_CXX03); + TranslationUnitDecl *FromTU = getTuDecl(Code, Lang_CXX03, "input.cc"); auto *ToClassProto = FirstDeclMatcher().match( ToTU, classTemplateDecl(hasName("Class"))); @@ -5391,7 +5328,7 @@ ASSERT_EQ(FromClassDef->getMostRecentDecl(), FromClassDef); ASSERT_EQ(FromClassProto->getMostRecentDecl(), FromClassProto); - auto *ImportedDef = Import(FromClassDef, Lang_CXX); + auto *ImportedDef = Import(FromClassDef, Lang_CXX03); // At import we should find the definition for 'Class' even if the // prototype (inside 'friend') for it comes first in the AST and is not // linked to the definition. @@ -5419,7 +5356,7 @@ class X{}; }; )", - Lang_CXX); + Lang_CXX03); auto *ToX = FirstDeclMatcher().match( ToTU, cxxRecordDecl(hasName("X"))); @@ -5434,10 +5371,10 @@ R"( class X; )", - Lang_CXX); + Lang_CXX03); auto *FromX = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("X"))); - auto *ImportedX = Import(FromX, Lang_CXX); + auto *ImportedX = Import(FromX, Lang_CXX03); // The lookup must find the existing class definition in the LinkageSpecDecl. // Then the importer renders the existing and the new decl into one chain. EXPECT_EQ(ImportedX->getCanonicalDecl(), ToX->getCanonicalDecl()); @@ -5461,8 +5398,8 @@ "__SVBool_t" }; - TranslationUnitDecl *ToTU = getToTuDecl("", Lang_CXX); - TranslationUnitDecl *FromTU = getTuDecl("", Lang_CXX, "input.cc"); + TranslationUnitDecl *ToTU = getToTuDecl("", Lang_CXX03); + TranslationUnitDecl *FromTU = getTuDecl("", Lang_CXX03, "input.cc"); for (auto *TypeName : TypeNames) { auto *ToTypedef = FirstDeclMatcher().match( ToTU, typedefDecl(hasName(TypeName))); @@ -5472,7 +5409,7 @@ FromTU, typedefDecl(hasName(TypeName))); QualType FromType = FromTypedef->getUnderlyingType(); - QualType ImportedType = ImportType(FromType, FromTypedef, Lang_CXX); + QualType ImportedType = ImportType(FromType, FromTypedef, Lang_CXX03); EXPECT_EQ(ImportedType, ToType); } } @@ -5606,7 +5543,7 @@ auto x = []{} = {}; auto x2 = x; } )", - Lang_CXX2a, "input0.cc"); + Lang_CXX20, "input0.cc"); auto FromF = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); // We have only one lambda class. @@ -5614,7 +5551,7 @@ DeclCounter().match(FromTU, cxxRecordDecl(isLambda())), 1u); - FunctionDecl *ToF = Import(FromF, Lang_CXX2a); + FunctionDecl *ToF = Import(FromF, Lang_CXX20); EXPECT_TRUE(ToF); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); // We have only one lambda class after the import. @@ -5630,7 +5567,7 @@ auto xb = []{} = {}; } )", - Lang_CXX2a, "input0.cc"); + Lang_CXX20, "input0.cc"); auto FromF = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); // We have two lambda classes. @@ -5638,7 +5575,7 @@ DeclCounter().match(FromTU, cxxRecordDecl(isLambda())), 2u); - FunctionDecl *ToF = Import(FromF, Lang_CXX2a); + FunctionDecl *ToF = Import(FromF, Lang_CXX20); EXPECT_TRUE(ToF); TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); // We have two lambda classes after the import. @@ -5862,18 +5799,18 @@ SourceLocation Location1; { auto Pattern = varDecl(hasName("X")); - Decl *FromTU = getTuDecl("int X;", Lang_C, "input0.c"); + Decl *FromTU = getTuDecl("int X;", Lang_C99, "input0.c"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - Location1 = Import(FromD, Lang_C)->getLocation(); + Location1 = Import(FromD, Lang_C99)->getLocation(); } SourceLocation Location2; { auto Pattern = varDecl(hasName("Y")); - Decl *FromTU = getTuDecl("int Y;", Lang_C, "input1.c"); + Decl *FromTU = getTuDecl("int Y;", Lang_C99, "input1.c"); auto *FromD = FirstDeclMatcher().match(FromTU, Pattern); - Location2 = Import(FromD, Lang_C)->getLocation(); + Location2 = Import(FromD, Lang_C99)->getLocation(); } SourceManager &ToSM = ToAST->getSourceManager(); @@ -5899,14 +5836,14 @@ std::string Path = "input0.c"; std::string Source = "int X;"; - TranslationUnitDecl *FromTU = getTuDecl(Source, Lang_C, Path); + TranslationUnitDecl *FromTU = getTuDecl(Source, Lang_C99, Path); SourceLocation ImportedLoc; { // Import the VarDecl to trigger the importing of the FileID. auto Pattern = varDecl(hasName("X")); VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern); - ImportedLoc = Import(FromD, Lang_C)->getLocation(); + ImportedLoc = Import(FromD, Lang_C99)->getLocation(); } // Make sure the imported buffer has the original contents. @@ -5919,7 +5856,7 @@ // Test importing overwritten file buffers. std::string Path = "input0.c"; - TranslationUnitDecl *FromTU = getTuDecl("int X;", Lang_C, Path); + TranslationUnitDecl *FromTU = getTuDecl("int X;", Lang_C99, Path); // Overwrite the file buffer for our input file with new content. const std::string Contents = "overwritten contents"; @@ -5939,7 +5876,7 @@ // Import the VarDecl to trigger the importing of the FileID. auto Pattern = varDecl(hasName("X")); VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern); - ImportedLoc = Import(FromD, Lang_C)->getLocation(); + ImportedLoc = Import(FromD, Lang_C99)->getLocation(); } // Make sure the imported buffer has the overwritten contents. @@ -6024,7 +5961,7 @@ TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) { // Create an empty TU. - TranslationUnitDecl *FromTU = getTuDecl("", Lang_CXX, "input.cpp"); + TranslationUnitDecl *FromTU = getTuDecl("", Lang_CXX03, "input.cpp"); // Create and add the test ExternalASTSource. std::vector CompletedTags; @@ -6042,7 +5979,7 @@ // Do a minimal import of the created class. EXPECT_EQ(0U, CompletedTags.size()); - Import(Record, Lang_CXX); + Import(Record, Lang_CXX03); EXPECT_EQ(0U, CompletedTags.size()); // Import the definition of the created class. diff --git a/clang/unittests/AST/MatchVerifier.h b/clang/unittests/AST/MatchVerifier.h --- a/clang/unittests/AST/MatchVerifier.h +++ b/clang/unittests/AST/MatchVerifier.h @@ -36,7 +36,7 @@ testing::AssertionResult match(const std::string &Code, const MatcherType &AMatcher) { std::vector Args; - return match(Code, AMatcher, Args, Lang_CXX); + return match(Code, AMatcher, Args, Lang_CXX03); } template @@ -88,16 +88,16 @@ StringRef FileName; switch (L) { - case Lang_C: - Args.push_back("-std=c99"); - FileName = "input.c"; - break; case Lang_C89: Args.push_back("-std=c89"); FileName = "input.c"; break; - case Lang_CXX: - Args.push_back("-std=c++98"); + case Lang_C99: + Args.push_back("-std=c99"); + FileName = "input.c"; + break; + case Lang_CXX03: + Args.push_back("-std=c++03"); FileName = "input.cc"; break; case Lang_CXX11: @@ -112,8 +112,8 @@ Args.push_back("-std=c++17"); FileName = "input.cc"; break; - case Lang_CXX2a: - Args.push_back("-std=c++2a"); + case Lang_CXX20: + Args.push_back("-std=c++20"); FileName = "input.cc"; break; case Lang_OpenCL: diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp --- a/clang/unittests/AST/SourceLocationTest.cpp +++ b/clang/unittests/AST/SourceLocationTest.cpp @@ -82,13 +82,13 @@ TEST(ParmVarDecl, KNRLocation) { LocationVerifier Verifier; Verifier.expectLocation(1, 8); - EXPECT_TRUE(Verifier.match("void f(i) {}", varDecl(), Lang_C)); + EXPECT_TRUE(Verifier.match("void f(i) {}", varDecl(), Lang_C99)); } TEST(ParmVarDecl, KNRRange) { RangeVerifier Verifier; Verifier.expectRange(1, 8, 1, 8); - EXPECT_TRUE(Verifier.match("void f(i) {}", varDecl(), Lang_C)); + EXPECT_TRUE(Verifier.match("void f(i) {}", varDecl(), Lang_C99)); } TEST(CXXNewExpr, ArrayRange) { @@ -814,7 +814,7 @@ std::vector Args; Args.push_back("-fms-extensions"); EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()), - Args, Lang_CXX)); + Args, Lang_CXX03)); Verifier.expectRange(1, 10, 1, 10); EXPECT_TRUE( diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp b/clang/unittests/AST/StructuralEquivalenceTest.cpp --- a/clang/unittests/AST/StructuralEquivalenceTest.cpp +++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -101,41 +101,41 @@ }; TEST_F(StructuralEquivalenceTest, Int) { - auto Decls = makeNamedDecls("int foo;", "int foo;", Lang_CXX); + auto Decls = makeNamedDecls("int foo;", "int foo;", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(Decls)); } TEST_F(StructuralEquivalenceTest, IntVsSignedInt) { - auto Decls = makeNamedDecls("int foo;", "signed int foo;", Lang_CXX); + auto Decls = makeNamedDecls("int foo;", "signed int foo;", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(Decls)); } TEST_F(StructuralEquivalenceTest, Char) { - auto Decls = makeNamedDecls("char foo;", "char foo;", Lang_CXX); + auto Decls = makeNamedDecls("char foo;", "char foo;", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(Decls)); } // This test is disabled for now. // FIXME Whether this is equivalent is dependendant on the target. TEST_F(StructuralEquivalenceTest, DISABLED_CharVsSignedChar) { - auto Decls = makeNamedDecls("char foo;", "signed char foo;", Lang_CXX); + auto Decls = makeNamedDecls("char foo;", "signed char foo;", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(Decls)); } TEST_F(StructuralEquivalenceTest, ForwardRecordDecl) { - auto Decls = makeNamedDecls("struct foo;", "struct foo;", Lang_CXX); + auto Decls = makeNamedDecls("struct foo;", "struct foo;", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(Decls)); } TEST_F(StructuralEquivalenceTest, IntVsSignedIntInStruct) { auto Decls = makeNamedDecls("struct foo { int x; };", - "struct foo { signed int x; };", Lang_CXX); + "struct foo { signed int x; };", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(Decls)); } TEST_F(StructuralEquivalenceTest, CharVsSignedCharInStruct) { auto Decls = makeNamedDecls("struct foo { char x; };", - "struct foo { signed char x; };", Lang_CXX); + "struct foo { signed char x; };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(Decls)); } @@ -143,8 +143,7 @@ auto Decls = makeDecls( R"(template struct foo; template<> struct foo{};)", R"(template struct foo; template<> struct foo{};)", - Lang_CXX, - classTemplateSpecializationDecl()); + Lang_CXX03, classTemplateSpecializationDecl()); auto Spec0 = get<0>(Decls); auto Spec1 = get<1>(Decls); EXPECT_TRUE(testStructuralMatch(Spec0, Spec1)); @@ -154,8 +153,7 @@ auto Decls = makeDecls( R"(template struct foo; template<> struct foo{};)", R"(template struct foo; template<> struct foo{};)", - Lang_CXX, - classTemplateSpecializationDecl()); + Lang_CXX03, classTemplateSpecializationDecl()); auto Spec0 = get<0>(Decls); auto Spec1 = get<1>(Decls); EXPECT_FALSE(testStructuralMatch(Spec0, Spec1)); @@ -173,8 +171,7 @@ template struct foo; template<> struct foo : true_type {}; )", - Lang_CXX, - classTemplateSpecializationDecl()); + Lang_CXX03, classTemplateSpecializationDecl()); EXPECT_FALSE(testStructuralMatch(Decls)); } @@ -192,7 +189,7 @@ } void foo(NS::Derived &); )"; - auto Decls = makeNamedDecls(Code, Code, Lang_CXX); + auto Decls = makeNamedDecls(Code, Code, Lang_CXX03); NamespaceDecl *NS = LastDeclMatcher().match(get<1>(Decls), namespaceDecl()); @@ -208,7 +205,7 @@ TEST_F(StructuralEquivalenceTest, WrongOrderOfFieldsInClass) { auto Code = "class X { int a; int b; };"; - auto Decls = makeNamedDecls(Code, Code, Lang_CXX, "X"); + auto Decls = makeNamedDecls(Code, Code, Lang_CXX03, "X"); CXXRecordDecl *RD = FirstDeclMatcher().match( get<1>(Decls), cxxRecordDecl(hasName("X"))); @@ -226,56 +223,48 @@ }; TEST_F(StructuralEquivalenceFunctionTest, TemplateVsNonTemplate) { - auto t = makeNamedDecls( - "void foo();", - "template void foo();", - Lang_CXX); + auto t = makeNamedDecls("void foo();", "template void foo();", + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, DifferentOperators) { auto t = makeDecls( - "struct X{}; bool operator<(X, X);", - "struct X{}; bool operator==(X, X);", Lang_CXX, - functionDecl(hasOverloadedOperatorName("<")), + "struct X{}; bool operator<(X, X);", "struct X{}; bool operator==(X, X);", + Lang_CXX03, functionDecl(hasOverloadedOperatorName("<")), functionDecl(hasOverloadedOperatorName("=="))); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, SameOperators) { auto t = makeDecls( - "struct X{}; bool operator<(X, X);", - "struct X{}; bool operator<(X, X);", Lang_CXX, - functionDecl(hasOverloadedOperatorName("<")), + "struct X{}; bool operator<(X, X);", "struct X{}; bool operator<(X, X);", + Lang_CXX03, functionDecl(hasOverloadedOperatorName("<")), functionDecl(hasOverloadedOperatorName("<"))); EXPECT_TRUE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, CtorVsDtor) { - auto t = makeDecls( - "struct X{ X(); };", - "struct X{ ~X(); };", Lang_CXX, - cxxConstructorDecl(), - cxxDestructorDecl()); + auto t = makeDecls("struct X{ X(); };", "struct X{ ~X(); };", + Lang_CXX03, cxxConstructorDecl(), + cxxDestructorDecl()); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ParamConstWithRef) { - auto t = makeNamedDecls("void foo(int&);", - "void foo(const int&);", Lang_CXX); + auto t = + makeNamedDecls("void foo(int&);", "void foo(const int&);", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ParamConstSimple) { - auto t = makeNamedDecls("void foo(int);", - "void foo(const int);", Lang_CXX); + auto t = makeNamedDecls("void foo(int);", "void foo(const int);", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); // consider this OK } TEST_F(StructuralEquivalenceFunctionTest, Throw) { - auto t = makeNamedDecls("void foo();", - "void foo() throw();", Lang_CXX); + auto t = makeNamedDecls("void foo();", "void foo() throw();", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -328,14 +317,12 @@ } TEST_F(StructuralEquivalenceFunctionTest, ReturnType) { - auto t = makeNamedDecls("char foo();", - "int foo();", Lang_CXX); + auto t = makeNamedDecls("char foo();", "int foo();", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ReturnConst) { - auto t = makeNamedDecls("char foo();", - "const char foo();", Lang_CXX); + auto t = makeNamedDecls("char foo();", "const char foo();", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -346,40 +333,33 @@ } TEST_F(StructuralEquivalenceFunctionTest, ParamCount) { - auto t = makeNamedDecls("void foo(int);", - "void foo(int, int);", Lang_CXX); + auto t = makeNamedDecls("void foo(int);", "void foo(int, int);", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ParamType) { - auto t = makeNamedDecls("void foo(int);", - "void foo(char);", Lang_CXX); + auto t = makeNamedDecls("void foo(int);", "void foo(char);", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ParamName) { - auto t = makeNamedDecls("void foo(int a);", - "void foo(int b);", Lang_CXX); + auto t = makeNamedDecls("void foo(int a);", "void foo(int b);", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, Variadic) { - auto t = makeNamedDecls("void foo(int x...);", - "void foo(int x);", Lang_CXX); + auto t = + makeNamedDecls("void foo(int x...);", "void foo(int x);", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ParamPtr) { - auto t = makeNamedDecls("void foo(int *);", - "void foo(int);", Lang_CXX); + auto t = makeNamedDecls("void foo(int *);", "void foo(int);", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, NameInParen) { - auto t = makeNamedDecls( - "void ((foo))();", - "void foo();", - Lang_CXX); + auto t = makeNamedDecls("void ((foo))();", "void foo();", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } @@ -400,10 +380,8 @@ } TEST_F(StructuralEquivalenceFunctionTest, FunctionsWithDifferentNoreturnAttr) { - auto t = makeNamedDecls( - "__attribute__((noreturn)) void foo();", - " void foo();", - Lang_C); + auto t = makeNamedDecls("__attribute__((noreturn)) void foo();", + " void foo();", Lang_C99); EXPECT_TRUE(testStructuralMatch(t)); } @@ -413,10 +391,8 @@ if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).getArch() != llvm::Triple::x86_64) return; - auto t = makeNamedDecls( - "__attribute__((preserve_all)) void foo();", - "__attribute__((ms_abi)) void foo();", - Lang_C); + auto t = makeNamedDecls("__attribute__((preserve_all)) void foo();", + "__attribute__((ms_abi)) void foo();", Lang_C99); EXPECT_FALSE(testStructuralMatch(t)); } @@ -426,8 +402,7 @@ return; auto t = makeNamedDecls( "__attribute__((no_caller_saved_registers)) void foo();", - " void foo();", - Lang_C); + " void foo();", Lang_C99); EXPECT_FALSE(testStructuralMatch(t)); } @@ -435,35 +410,35 @@ }; TEST_F(StructuralEquivalenceCXXMethodTest, Virtual) { - auto t = makeDecls( - "struct X { void foo(); };", - "struct X { virtual void foo(); };", Lang_CXX, - cxxMethodDecl(hasName("foo"))); + auto t = makeDecls("struct X { void foo(); };", + "struct X { virtual void foo(); };", + Lang_CXX03, cxxMethodDecl(hasName("foo"))); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceCXXMethodTest, Pure) { auto t = makeNamedDecls("struct X { virtual void foo(); };", - "struct X { virtual void foo() = 0; };", Lang_CXX); + "struct X { virtual void foo() = 0; };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceCXXMethodTest, DISABLED_Final) { // The final-ness is not checked yet. - auto t = makeNamedDecls("struct X { virtual void foo(); };", - "struct X { virtual void foo() final; };", Lang_CXX); + auto t = + makeNamedDecls("struct X { virtual void foo(); };", + "struct X { virtual void foo() final; };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceCXXMethodTest, Const) { auto t = makeNamedDecls("struct X { void foo(); };", - "struct X { void foo() const; };", Lang_CXX); + "struct X { void foo() const; };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceCXXMethodTest, Static) { auto t = makeNamedDecls("struct X { void foo(); };", - "struct X { static void foo(); };", Lang_CXX); + "struct X { static void foo(); };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -480,10 +455,9 @@ } TEST_F(StructuralEquivalenceCXXMethodTest, AccessSpecifier) { - auto t = makeDecls( - "struct X { public: void foo(); };", - "struct X { private: void foo(); };", Lang_CXX, - cxxMethodDecl(hasName("foo"))); + auto t = makeDecls("struct X { public: void foo(); };", + "struct X { private: void foo(); };", + Lang_CXX03, cxxMethodDecl(hasName("foo"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -494,15 +468,15 @@ } TEST_F(StructuralEquivalenceCXXMethodTest, Constructor) { - auto t = makeDecls( - "void foo();", "struct foo { foo(); };", Lang_CXX, - functionDecl(hasName("foo")), cxxConstructorDecl(hasName("foo"))); + auto t = makeDecls("void foo();", "struct foo { foo(); };", + Lang_CXX03, functionDecl(hasName("foo")), + cxxConstructorDecl(hasName("foo"))); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceCXXMethodTest, ConstructorParam) { auto t = makeDecls("struct X { X(); };", - "struct X { X(int); };", Lang_CXX, + "struct X { X(int); };", Lang_CXX03, cxxConstructorDecl(hasName("X"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -532,19 +506,18 @@ } TEST_F(StructuralEquivalenceCXXMethodTest, Operator) { - auto t = makeDecls( - "struct X { int operator +(int); };", - "struct X { int operator -(int); };", Lang_CXX, - functionDecl(hasOverloadedOperatorName("+")), - functionDecl(hasOverloadedOperatorName("-"))); + auto t = + makeDecls("struct X { int operator +(int); };", + "struct X { int operator -(int); };", Lang_CXX03, + functionDecl(hasOverloadedOperatorName("+")), + functionDecl(hasOverloadedOperatorName("-"))); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceCXXMethodTest, OutOfClass1) { auto t = makeDecls( "struct X { virtual void f(); }; void X::f() { }", - "struct X { virtual void f() { }; };", - Lang_CXX, + "struct X { virtual void f() { }; };", Lang_CXX03, functionDecl(allOf(hasName("f"), isDefinition()))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -552,8 +525,7 @@ TEST_F(StructuralEquivalenceCXXMethodTest, OutOfClass2) { auto t = makeDecls( "struct X { virtual void f(); }; void X::f() { }", - "struct X { void f(); }; void X::f() { }", - Lang_CXX, + "struct X { void f(); }; void X::f() { }", Lang_CXX03, functionDecl(allOf(hasName("f"), isDefinition()))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -567,54 +539,43 @@ }; TEST_F(StructuralEquivalenceRecordTest, Name) { - auto t = makeDecls( - "struct A{ };", - "struct B{ };", - Lang_CXX, - cxxRecordDecl(hasName("A")), - cxxRecordDecl(hasName("B"))); + auto t = makeDecls("struct A{ };", "struct B{ };", Lang_CXX03, + cxxRecordDecl(hasName("A")), + cxxRecordDecl(hasName("B"))); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceRecordTest, Fields) { - auto t = makeNamedDecls( - "struct foo{ int x; };", - "struct foo{ char x; };", - Lang_CXX); + auto t = makeNamedDecls("struct foo{ int x; };", "struct foo{ char x; };", + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceRecordTest, DISABLED_Methods) { // Currently, methods of a class are not checked at class equivalence. - auto t = makeNamedDecls( - "struct foo{ int x(); };", - "struct foo{ char x(); };", - Lang_CXX); + auto t = makeNamedDecls("struct foo{ int x(); };", "struct foo{ char x(); };", + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceRecordTest, Bases) { - auto t = makeNamedDecls( - "struct A{ }; struct foo: A { };", - "struct B{ }; struct foo: B { };", - Lang_CXX); + auto t = makeNamedDecls("struct A{ }; struct foo: A { };", + "struct B{ }; struct foo: B { };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceRecordTest, InheritanceVirtual) { - auto t = makeNamedDecls( - "struct A{ }; struct foo: A { };", - "struct A{ }; struct foo: virtual A { };", - Lang_CXX); + auto t = + makeNamedDecls("struct A{ }; struct foo: A { };", + "struct A{ }; struct foo: virtual A { };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceRecordTest, DISABLED_InheritanceType) { // Access specifier in inheritance is not checked yet. - auto t = makeNamedDecls( - "struct A{ }; struct foo: public A { };", - "struct A{ }; struct foo: private A { };", - Lang_CXX); + auto t = + makeNamedDecls("struct A{ }; struct foo: public A { };", + "struct A{ }; struct foo: private A { };", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -627,7 +588,7 @@ int a; }; )"; - auto t = makeNamedDecls(Code, Code, Lang_CXX); + auto t = makeNamedDecls(Code, Code, Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } @@ -643,7 +604,7 @@ } entry1; }; )", - "", Lang_C); + "", Lang_C99); auto *TU = get<0>(t); auto *Entry0 = FirstDeclMatcher().match(TU, fieldDecl(hasName("entry0"))); @@ -670,7 +631,7 @@ }; }; )", - "", Lang_C); + "", Lang_C99); auto *TU = get<0>(t); auto *A = FirstDeclMatcher().match( TU, indirectFieldDecl(hasName("a"))); @@ -702,7 +663,7 @@ struct { int a; }; }; )", - Lang_C); + Lang_C99); auto *TU = get<0>(t); auto *A = FirstDeclMatcher().match( @@ -742,7 +703,7 @@ } entry1; }; )"; - auto t = makeTuDecls(Code, Code, Lang_C); + auto t = makeTuDecls(Code, Code, Lang_C99); auto *FromTU = get<0>(t); auto *Entry1 = @@ -766,11 +727,9 @@ } TEST_F(StructuralEquivalenceRecordTest, TemplateVsNonTemplate) { - auto t = makeDecls( - "struct A { };", - "template struct A { };", - Lang_CXX, - cxxRecordDecl(hasName("A"))); + auto t = makeDecls("struct A { };", + "template struct A { };", + Lang_CXX03, cxxRecordDecl(hasName("A"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -853,16 +812,15 @@ } TEST_F(StructuralEquivalenceTest, CompareSameDeclWithMultiple) { - auto t = makeNamedDecls( - "struct A{ }; struct B{ }; void foo(A a, A b);", - "struct A{ }; struct B{ }; void foo(A a, B b);", - Lang_CXX); + auto t = makeNamedDecls("struct A{ }; struct B{ }; void foo(A a, A b);", + "struct A{ }; struct B{ }; void foo(A a, B b);", + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceTest, ExplicitBoolDifferent) { auto Decls = makeNamedDecls("struct foo {explicit(false) foo(int);};", - "struct foo {explicit(true) foo(int);};", Lang_CXX2a); + "struct foo {explicit(true) foo(int);};", Lang_CXX20); CXXConstructorDecl *First = FirstDeclMatcher().match( get<0>(Decls), cxxConstructorDecl(hasName("foo"))); CXXConstructorDecl *Second = FirstDeclMatcher().match( @@ -872,7 +830,7 @@ TEST_F(StructuralEquivalenceTest, ExplicitBoolSame) { auto Decls = makeNamedDecls("struct foo {explicit(true) foo(int);};", - "struct foo {explicit(true) foo(int);};", Lang_CXX2a); + "struct foo {explicit(true) foo(int);};", Lang_CXX20); CXXConstructorDecl *First = FirstDeclMatcher().match( get<0>(Decls), cxxConstructorDecl(hasName("foo"))); CXXConstructorDecl *Second = FirstDeclMatcher().match( @@ -911,25 +869,26 @@ TEST_F(StructuralEquivalenceTemplateTest, ExactlySameTemplates) { auto t = makeNamedDecls("template struct foo;", - "template struct foo;", Lang_CXX); + "template struct foo;", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgName) { auto t = makeNamedDecls("template struct foo;", - "template struct foo;", Lang_CXX); + "template struct foo;", Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgKind) { auto t = makeNamedDecls("template struct foo;", - "template struct foo;", Lang_CXX); + "template struct foo;", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceTemplateTest, ExplicitBoolSame) { - auto Decls = makeNamedDecls("template struct foo {explicit(b) foo(int);};", - "template struct foo {explicit(b) foo(int);};", Lang_CXX2a); + auto Decls = makeNamedDecls( + "template struct foo {explicit(b) foo(int);};", + "template struct foo {explicit(b) foo(int);};", Lang_CXX20); CXXConstructorDecl *First = FirstDeclMatcher().match( get<0>(Decls), cxxConstructorDecl(hasName("foo"))); CXXConstructorDecl *Second = FirstDeclMatcher().match( @@ -938,8 +897,9 @@ } TEST_F(StructuralEquivalenceTemplateTest, ExplicitBoolDifference) { - auto Decls = makeNamedDecls("template struct foo {explicit(b) foo(int);};", - "template struct foo {explicit(!b) foo(int);};", Lang_CXX2a); + auto Decls = makeNamedDecls( + "template struct foo {explicit(b) foo(int);};", + "template struct foo {explicit(!b) foo(int);};", Lang_CXX20); CXXConstructorDecl *First = FirstDeclMatcher().match( get<0>(Decls), cxxConstructorDecl(hasName("foo"))); CXXConstructorDecl *Second = FirstDeclMatcher().match( @@ -973,7 +933,7 @@ // Instantiate with substitution Arg into P1. template class Templ ; )", - Lang_CXX, classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -1004,7 +964,7 @@ // Instantiate with substitution Arg into P1. template class Templ ; )", - Lang_CXX, classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1112,7 +1072,7 @@ void f(); }; )", - Lang_CXX, + Lang_CXX03, functionTemplateDecl(hasName("f"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1141,7 +1101,7 @@ void f(); }; )", - Lang_CXX, + Lang_CXX03, functionTemplateDecl(hasName("f"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1167,8 +1127,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, - classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -1194,8 +1153,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, - classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1220,8 +1178,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, - classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -1247,8 +1204,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, - classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1272,8 +1228,7 @@ template struct Primary; } )", - Lang_CXX, - classTemplateSpecializationDecl(hasName("Primary"))); + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } struct StructuralEquivalenceCacheTest : public StructuralEquivalenceTest { @@ -1306,7 +1261,7 @@ class B {}; void x(A, B); )", - Lang_CXX); + Lang_CXX03); StructuralEquivalenceContext Ctx( get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), @@ -1343,7 +1298,7 @@ friend void y(B *); }; )", - Lang_CXX); + Lang_CXX03); StructuralEquivalenceContext Ctx( get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), @@ -1382,7 +1337,7 @@ friend void x(A *); }; )", - Lang_CXX); + Lang_CXX03); StructuralEquivalenceContext Ctx( get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -52,14 +52,14 @@ std::string Target; bool isCXX() const { - return Language == Lang_CXX || Language == Lang_CXX11 || + return Language == Lang_CXX03 || Language == Lang_CXX11 || Language == Lang_CXX14 || Language == Lang_CXX17 || - Language == Lang_CXX2a; + Language == Lang_CXX20; } bool isCXX11OrLater() const { return Language == Lang_CXX11 || Language == Lang_CXX14 || - Language == Lang_CXX17 || Language == Lang_CXX2a; + Language == Lang_CXX17 || Language == Lang_CXX20; } bool hasDelayedTemplateParsing() const { @@ -88,8 +88,8 @@ static std::vector &allConfigs() { static std::vector all_configs = []() { std::vector all_configs; - for (TestLanguage lang : {Lang_C, Lang_C89, Lang_CXX, Lang_CXX11, - Lang_CXX14, Lang_CXX17, Lang_CXX2a}) { + for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11, + Lang_CXX14, Lang_CXX17, Lang_CXX20}) { TestClangConfig config; config.Language = lang; config.Target = "x86_64-pc-linux-gnu";