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,9 +19,9 @@ namespace clang { enum TestLanguage { - Lang_C, Lang_C89, - Lang_CXX, + Lang_C99, + Lang_CXX03, Lang_CXX11, Lang_CXX14, Lang_CXX17, 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"}; 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); @@ -475,17 +475,17 @@ MatchVerifier Verifier; testImport( "void declToImport() { (void)\"foo\"; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( stringLiteral(hasType(asString("const char [4]")))))); testImport( "void declToImport() { (void)L\"foo\"; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( stringLiteral(hasType(asString("const wchar_t [4]")))))); testImport( "void declToImport() { (void) \"foo\" \"bar\"; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( stringLiteral(hasType(asString("const char [7]")))))); } @@ -497,7 +497,7 @@ // condition. testImport( "void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant(chooseExpr()))); } @@ -505,7 +505,7 @@ MatchVerifier Verifier; testImport( "void declToImport() { (void)__null; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger()))))); } @@ -522,21 +522,21 @@ MatchVerifier Verifier; testImport( "void declToImport() { (void)1.0; }", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant( floatLiteral(equals(1.0), hasType(asString("double")))))); testImport( "void declToImport() { (void)1.0e-5f; }", - Lang_C, "", Lang_C, Verifier, + 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()))); } @@ -554,7 +554,7 @@ "void declToImport() {" " struct s { int x; long y; unsigned z; }; " " (void)(struct s){ 42, 0L, 1U }; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( compoundLiteralExpr( hasType(asString("struct s")), @@ -572,7 +572,7 @@ MatchVerifier Verifier; testImport( "class declToImport { void f() { (void)this; } };", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, cxxRecordDecl( hasMethod( hasDescendant( @@ -585,7 +585,7 @@ MatchVerifier Verifier; testImport( "void declToImport() { int *ptr; __atomic_load_n(ptr, 1); }", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant( atomicExpr( has(ignoringParenImpCasts( @@ -598,7 +598,7 @@ MatchVerifier Verifier; testImport( "void declToImport() { loop: goto loop; (void)&&loop; }", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl( hasDescendant( labelStmt(hasDeclaration(labelDecl(hasName("loop"))))), @@ -618,7 +618,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( @@ -633,7 +633,7 @@ MatchVerifier Verifier; testImport( "void declToImport() { int b; switch (b) { case 1: break; } }", - Lang_C, "", Lang_C, Verifier, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant( switchStmt(has(compoundStmt(has(caseStmt()))))))); } @@ -642,7 +642,7 @@ 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")), @@ -657,7 +657,7 @@ MatchVerifier Verifier; testImport( "void declToImport() { (void)(true ? 1 : -5); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( conditionalOperator( hasCondition(cxxBoolLiteral(equals(true))), @@ -670,7 +670,7 @@ 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,7 +692,7 @@ " 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, + Lang_C99, "", Lang_C99, Verifier, functionDecl(hasDescendant( initListExpr( has(designatedInitExpr( @@ -714,7 +714,7 @@ // __func__ expands as StringLiteral("declToImport") testImport( "void declToImport() { (void)__func__; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( predefinedExpr( hasType( @@ -730,7 +730,7 @@ " 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, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( initListExpr( has( @@ -757,7 +757,7 @@ testImport( "void declToImport(__builtin_va_list list, ...) {" " (void)__builtin_va_arg(list, int); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( cStyleCastExpr(hasSourceExpression(vaArgExpr()))))); } @@ -767,7 +767,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( @@ -786,7 +786,7 @@ MatchVerifier Verifier; testImport( "template void declToImport() { };", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl()); } @@ -799,7 +799,7 @@ " (void)d.t;" "}" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl(hasDescendant( cStyleCastExpr(has(cxxDependentScopeMemberExpr()))))); testImport( @@ -809,7 +809,7 @@ " (void)(&d)->t;" "}" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl(hasDescendant( cStyleCastExpr(has(cxxDependentScopeMemberExpr()))))); } @@ -871,7 +871,7 @@ "struct declToImport {" " typename A::template B a;" "};", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, classTemplateDecl(has(cxxRecordDecl(has( fieldDecl(hasType(dependentTemplateSpecializationType()))))))); } @@ -917,7 +917,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 +961,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 +972,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,11 +985,11 @@ // 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); } @@ -997,11 +997,11 @@ Decl *FromTU = getTuDecl( "#define NONAME_SIZEOF(type) sizeof(struct{type *dummy;}) \n" "int declToImport(){ return NONAME_SIZEOF(int); }", - 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); ASSERT_TRUE(To); EXPECT_TRUE(MatchVerifier().match( To, functionDecl(hasName("declToImport"), @@ -1014,11 +1014,11 @@ 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"); + 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,7 +1033,7 @@ " T t;" " p->T::~T();" "}", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant( callExpr(has(cxxPseudoDestructorExpr()))))); } @@ -1043,7 +1043,7 @@ testImport( "namespace foo { int bar; }" "void declToImport() { using foo::bar; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionDecl(hasDescendant(usingDecl()))); } @@ -1065,7 +1065,7 @@ testImport( "namespace foo { int bar; }" "namespace declToImport { using foo::bar; }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, namespaceDecl(has(usingShadowDecl()))); } @@ -1078,7 +1078,7 @@ " (void)::template foo;" "}" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl(hasDescendant(unresolvedLookupExpr()))); } @@ -1091,7 +1091,7 @@ " d.t = T();" "}" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl(hasDescendant( binaryOperator(has(cxxUnresolvedConstructExpr()))))); testImport( @@ -1101,7 +1101,7 @@ " (&d)->t = T();" "}" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl(hasDescendant( binaryOperator(has(cxxUnresolvedConstructExpr()))))); } @@ -1114,13 +1114,13 @@ testImport( "template void declToImport() { T a = 1; }" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, functionTemplateDecl(hasAncestor(translationUnitDecl( unless(has(functionDecl(hasName("declToImport")))))))); testImport( "template struct declToImport { T t; };" "void instantiate() { declToImport(); }", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, classTemplateDecl(hasAncestor(translationUnitDecl( unless(has(cxxRecordDecl(hasName("declToImport")))))))); } @@ -1134,7 +1134,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,7 +1145,7 @@ "class declToImport {" " void f() { *this = declToImport(); }" "};", - Lang_CXX, "", Lang_CXX, Verifier, + Lang_CXX03, "", Lang_CXX03, Verifier, cxxRecordDecl(has(cxxMethodDecl(hasDescendant( cxxOperatorCallExpr()))))); } @@ -1156,14 +1156,14 @@ "template class declToImport {" " T data[Size];" "};", - Lang_CXX, "", Lang_CXX, Verifier, + 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); + "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 +1172,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 +1183,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 +1227,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 +1250,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 +1267,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); } @@ -1278,7 +1278,7 @@ Decl *From, *To; std::tie(From, To) = getImportedDecl( "void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }", - Lang_C, "", Lang_C); + Lang_C99, "", Lang_C99); auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext()); auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext()); @@ -1311,7 +1311,7 @@ } }; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; auto Matcher = functionDecl(hasName("declToImport"), @@ -1329,7 +1329,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 +1355,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 +1413,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 +1459,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 +1542,7 @@ struct declToImport { }; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; // Match the implicit Decl. @@ -1560,7 +1560,7 @@ struct declToImport { }; )", - Lang_CXX, "", Lang_CXX); + Lang_CXX03, "", Lang_CXX03); MatchVerifier Verifier; // Match the implicit Decl. @@ -1578,7 +1578,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 +1593,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 +1608,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 +1623,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 +1642,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 +1657,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 +1680,7 @@ template struct B; )", - Lang_CXX); + Lang_CXX03); ASSERT_EQ(1u, DeclCounterWithPredicate( [](const ClassTemplateDecl *T) { return T->isThisDeclarationADefinition(); @@ -1694,11 +1694,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 +1718,7 @@ struct B; )", - Lang_CXX); + Lang_CXX03); ASSERT_EQ(2u, DeclCounter().match( ToTU, cxxRecordDecl(unless(isImplicit())))); @@ -1728,11 +1728,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 +1761,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 +1788,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 +1812,7 @@ template <> struct B; )", - Lang_CXX); + Lang_CXX03); // We should have only one definition. ASSERT_EQ(1u, DeclCounterWithPredicate( [](const ClassTemplateSpecializationDecl *T) { @@ -1828,11 +1828,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 +1848,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 +1857,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 +1874,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 +1900,7 @@ struct { int b; }; }; )", - Lang_C, "input0.c"); + Lang_C99, "input0.c"); Decl *FromTU1 = getTuDecl( R"( @@ -1909,14 +1909,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 +1929,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"); + 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 +1955,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"); + "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 +1978,7 @@ struct A { static const int a = 1; }; - )", Lang_CXX); + )", Lang_CXX03); ExistingD = FirstDeclMatcher().match(ToTU, Pattern); } EXPECT_FALSE(ExistingD->isUsed(false)); @@ -1990,12 +1990,12 @@ }; 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 +2003,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 +2020,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 +2038,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 +2064,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 +2081,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 +2099,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 +2127,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 +2163,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 +2197,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 +2254,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 +2305,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); @@ -2323,14 +2323,14 @@ TranslationUnitDecl *FromTu = getTuDecl( "namespace NS0 { namespace { void f(); } }" "namespace NS1 { namespace { void f(); } }", - Lang_CXX, "input0.cc"); + 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 +2341,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 +2371,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 +2394,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 +2420,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 +2441,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 +2463,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 +2482,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 +2500,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 +2517,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 +2537,11 @@ Decl *FromTU = getTuDecl("struct X { friend void f(); };" "void f();", - Lang_CXX, + 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 +2556,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 +2573,11 @@ Decl *FromTU = getTuDecl("struct X { friend void f(){} };" "void f();", - Lang_CXX, + 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 +2592,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 +2615,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 +2644,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 +2667,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 +2690,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 +2703,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(); @@ -2731,7 +2731,7 @@ // `clang::Sema::CppLookupName()` and in `LookupDirect()`) // returns the found `NamedDecl` only if the set IDNS is matched "void f();", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromFriend = FirstDeclMatcher().match(FromTU, FunctionPattern); auto *FromNormal = @@ -2749,7 +2749,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(); @@ -2776,7 +2776,7 @@ TranslationUnitDecl *FromTU = getTuDecl( "void f();" "struct X { friend void f(); };", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromNormal = FirstDeclMatcher().match(FromTU, FunctionPattern); auto *FromFriend = @@ -2794,7 +2794,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 +2817,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 +2836,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 +2845,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); @@ -2861,7 +2861,7 @@ TranslationUnitDecl *FromTU = getTuDecl( "struct X { friend void f(); };" "void f();", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromFriendF = FirstDeclMatcher().match( FromTU, functionDecl(hasName("f"))); @@ -2876,7 +2876,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 +2902,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"))), @@ -3115,21 +3115,21 @@ Decl *ToR1; { Decl *FromTU = getTuDecl( - "struct A { };", Lang_CXX, "input0.cc"); + "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"); + "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); @@ -3139,18 +3139,18 @@ Decl *ToR1; { Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input0.cc"); + "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"); + "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); } @@ -3159,18 +3159,18 @@ Decl *ToF1; { Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input0.cc"); + "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"); + "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); } @@ -3179,18 +3179,18 @@ Decl *ToF1; { Decl *FromTU = getTuDecl( - "struct A { int x; };", Lang_CXX, "input0.cc"); + "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"); + "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); } @@ -3199,18 +3199,18 @@ Decl *ToM1; { Decl *FromTU = getTuDecl( - "struct A { void x(); }; void A::x() { }", Lang_CXX, "input0.cc"); + "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"); + "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); } @@ -3220,19 +3220,19 @@ { Decl *FromTU = getTuDecl( "struct A { void x(); }; void A::x() { }", - Lang_CXX, "input0.cc"); + 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"); + 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 +3250,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 +3594,7 @@ 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 +3618,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 +3649,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 +3676,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 +3694,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 +3712,14 @@ } 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 +3746,7 @@ }; }; )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromClass = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("F"), isDefinition())); @@ -3761,8 +3761,8 @@ 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 +3780,18 @@ 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 +3809,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 +3835,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 +3860,22 @@ { 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 +3896,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 +3916,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 +3935,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 +3943,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 +3965,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 +3994,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 +4019,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 +4061,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 +4105,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 +4114,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,7 +4129,7 @@ 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()); @@ -4137,7 +4137,7 @@ ASSERT_TRUE(MatchVerifier{}.match(FromTU, Pattern)); ASSERT_TRUE( - Import(FirstDeclMatcher().match(FromTU, Instantiation), Lang_CXX)); + Import(FirstDeclMatcher().match(FromTU, Instantiation), Lang_CXX03)); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); EXPECT_TRUE(MatchVerifier{}.match(ToTU, Pattern)); @@ -4152,7 +4152,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 = @@ -4161,7 +4161,7 @@ ASSERT_TRUE(MatchVerifier{}.match(FromTU, Pattern)); ASSERT_TRUE( - Import(FirstDeclMatcher().match(FromTU, Specialization), Lang_CXX)); + Import(FirstDeclMatcher().match(FromTU, Specialization), Lang_CXX03)); auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl(); EXPECT_TRUE(MatchVerifier{}.match(ToTU, Pattern)); @@ -4176,7 +4176,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 +4193,7 @@ ->doesThisDeclarationHaveABody()); } - ASSERT_TRUE(Import(FromSpecD, Lang_CXX)); + ASSERT_TRUE(Import(FromSpecD, Lang_CXX03)); { auto *TU = ToAST->getASTContext().getTranslationUnitDecl(); @@ -4239,11 +4239,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 +4255,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 +4311,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 +4324,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 +4349,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 +4385,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 +4420,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 +4455,7 @@ void foo(int); void foo(int, int); )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F0 = FirstDeclMatcher().match(ToTU, functionDecl()); @@ -4475,7 +4475,7 @@ void operator+(X, X); void operator-(X, X); )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *FPlus = FirstDeclMatcher().match( @@ -4501,7 +4501,7 @@ struct X {}; void operator+(X, X); )", - Lang_CXX); + Lang_CXX03); auto *ToPlus = FirstDeclMatcher().match( ToTU, functionDecl(hasOverloadedOperatorName("+"))); @@ -4510,7 +4510,7 @@ struct X {}; void operator+(X, X); )", - Lang_CXX); + Lang_CXX03); auto *FromPlus = FirstDeclMatcher().match( FromTU, functionDecl(hasOverloadedOperatorName("+"))); @@ -4533,7 +4533,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 +4603,7 @@ R"( class Y { template friend class F; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4626,7 +4626,7 @@ friend class F; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4648,7 +4648,7 @@ friend class F; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4666,7 +4666,7 @@ R"( class Y { friend void F(); }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = @@ -4689,7 +4689,7 @@ X xc; } )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); @@ -4731,7 +4731,7 @@ R"( class Y { template friend void F(); }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *F = FirstDeclMatcher().match( @@ -4754,7 +4754,7 @@ friend struct X; }; )", - Lang_CXX); + Lang_CXX03); ASTImporterLookupTable LT(*ToTU); auto *X = FirstDeclMatcher().match( @@ -4780,7 +4780,7 @@ B }; )", - Lang_C); + Lang_C99); ASTImporterLookupTable LT(*ToTU); auto *E = FirstDeclMatcher().match(ToTU, enumDecl(hasName("E"))); @@ -4820,7 +4820,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 +4849,7 @@ }; } )", - Lang_CXX); + Lang_CXX03); auto *FromFwd = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("X"), unless(isImplicit()))); auto *FromDef = LastDeclMatcher().match( @@ -4860,8 +4860,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 +4880,7 @@ template friend void foo(); }; )", - Lang_CXX); + Lang_CXX03); auto *Friend = FirstDeclMatcher().match( ToTU, functionTemplateDecl(hasName("foo"))); @@ -4888,10 +4888,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 +4927,7 @@ template <> class X { int a; }; )", - Lang_CXX); + Lang_CXX03); TranslationUnitDecl *FromTU = getTuDecl( R"( template @@ -4935,10 +4935,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. @@ -4959,11 +4959,11 @@ ErrorHappensAfterCreatingTheNodeButBeforeLinkingThatToTheAST) { TranslationUnitDecl *FromTU = getTuDecl( std::string("void foo() { ") + ErroneousStmt + " }", - Lang_CXX); + 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(); @@ -4987,12 +4987,12 @@ 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 @@ -5025,10 +5025,10 @@ 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 +5044,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 +5053,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); } @@ -5077,7 +5077,7 @@ class B {}; } // NS )", - Lang_CXX, "input0.cc"); + Lang_CXX03, "input0.cc"); auto *FromFRD = FirstDeclMatcher().match( FromTU, cxxRecordDecl(hasName("F"), isDefinition())); @@ -5090,13 +5090,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(); @@ -5151,10 +5151,10 @@ 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 +5169,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 +5178,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); } @@ -5188,7 +5188,7 @@ ImportedDeclWithErrorShouldFailTheImportOfDeclWhichMapToIt) { // We already have a fwd decl. TranslationUnitDecl *ToTU = getToTuDecl( - "class X;", Lang_CXX); + "class X;", Lang_CXX03); // Then we import a definition. { TranslationUnitDecl *FromTU = getTuDecl(std::string(R"( @@ -5197,10 +5197,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 +5232,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 +5367,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 +5391,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 +5419,7 @@ class X{}; }; )", - Lang_CXX); + Lang_CXX03); auto *ToX = FirstDeclMatcher().match( ToTU, cxxRecordDecl(hasName("X"))); @@ -5434,10 +5434,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 +5461,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 +5472,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); } } @@ -5862,18 +5862,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 +5899,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 +5919,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 +5939,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 +6024,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 +6042,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: 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,7 +143,7 @@ auto Decls = makeDecls( R"(template struct foo; template<> struct foo{};)", R"(template struct foo; template<> struct foo{};)", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl()); auto Spec0 = get<0>(Decls); auto Spec1 = get<1>(Decls); @@ -154,7 +154,7 @@ auto Decls = makeDecls( R"(template struct foo; template<> struct foo{};)", R"(template struct foo; template<> struct foo{};)", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl()); auto Spec0 = get<0>(Decls); auto Spec1 = get<1>(Decls); @@ -173,7 +173,7 @@ template struct foo; template<> struct foo : true_type {}; )", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl()); EXPECT_FALSE(testStructuralMatch(Decls)); } @@ -192,7 +192,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 +208,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"))); @@ -229,14 +229,14 @@ auto t = makeNamedDecls( "void foo();", "template void foo();", - Lang_CXX); + 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, + "struct X{}; bool operator==(X, X);", Lang_CXX03, functionDecl(hasOverloadedOperatorName("<")), functionDecl(hasOverloadedOperatorName("=="))); EXPECT_FALSE(testStructuralMatch(t)); @@ -245,7 +245,7 @@ TEST_F(StructuralEquivalenceFunctionTest, SameOperators) { auto t = makeDecls( "struct X{}; bool operator<(X, X);", - "struct X{}; bool operator<(X, X);", Lang_CXX, + "struct X{}; bool operator<(X, X);", Lang_CXX03, functionDecl(hasOverloadedOperatorName("<")), functionDecl(hasOverloadedOperatorName("<"))); EXPECT_TRUE(testStructuralMatch(t)); @@ -254,7 +254,7 @@ TEST_F(StructuralEquivalenceFunctionTest, CtorVsDtor) { auto t = makeDecls( "struct X{ X(); };", - "struct X{ ~X(); };", Lang_CXX, + "struct X{ ~X(); };", Lang_CXX03, cxxConstructorDecl(), cxxDestructorDecl()); EXPECT_FALSE(testStructuralMatch(t)); @@ -262,20 +262,20 @@ TEST_F(StructuralEquivalenceFunctionTest, ParamConstWithRef) { auto t = makeNamedDecls("void foo(int&);", - "void foo(const int&);", Lang_CXX); + "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); + "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); + "void foo() throw();", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -329,13 +329,13 @@ TEST_F(StructuralEquivalenceFunctionTest, ReturnType) { auto t = makeNamedDecls("char foo();", - "int foo();", Lang_CXX); + "int foo();", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } TEST_F(StructuralEquivalenceFunctionTest, ReturnConst) { auto t = makeNamedDecls("char foo();", - "const char foo();", Lang_CXX); + "const char foo();", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -347,31 +347,31 @@ TEST_F(StructuralEquivalenceFunctionTest, ParamCount) { auto t = makeNamedDecls("void foo(int);", - "void foo(int, int);", Lang_CXX); + "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); + "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); + "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); + "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); + "void foo(int);", Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -379,7 +379,7 @@ auto t = makeNamedDecls( "void ((foo))();", "void foo();", - Lang_CXX); + Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } @@ -403,7 +403,7 @@ auto t = makeNamedDecls( "__attribute__((noreturn)) void foo();", " void foo();", - Lang_C); + Lang_C99); EXPECT_TRUE(testStructuralMatch(t)); } @@ -416,7 +416,7 @@ auto t = makeNamedDecls( "__attribute__((preserve_all)) void foo();", "__attribute__((ms_abi)) void foo();", - Lang_C); + Lang_C99); EXPECT_FALSE(testStructuralMatch(t)); } @@ -427,7 +427,7 @@ auto t = makeNamedDecls( "__attribute__((no_caller_saved_registers)) void foo();", " void foo();", - Lang_C); + Lang_C99); EXPECT_FALSE(testStructuralMatch(t)); } @@ -437,33 +437,33 @@ TEST_F(StructuralEquivalenceCXXMethodTest, Virtual) { auto t = makeDecls( "struct X { void foo(); };", - "struct X { virtual void foo(); };", Lang_CXX, + "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); + "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)); } @@ -482,7 +482,7 @@ TEST_F(StructuralEquivalenceCXXMethodTest, AccessSpecifier) { auto t = makeDecls( "struct X { public: void foo(); };", - "struct X { private: void foo(); };", Lang_CXX, + "struct X { private: void foo(); };", Lang_CXX03, cxxMethodDecl(hasName("foo"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -495,14 +495,14 @@ TEST_F(StructuralEquivalenceCXXMethodTest, Constructor) { auto t = makeDecls( - "void foo();", "struct foo { foo(); };", Lang_CXX, + "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)); } @@ -534,7 +534,7 @@ TEST_F(StructuralEquivalenceCXXMethodTest, Operator) { auto t = makeDecls( "struct X { int operator +(int); };", - "struct X { int operator -(int); };", Lang_CXX, + "struct X { int operator -(int); };", Lang_CXX03, functionDecl(hasOverloadedOperatorName("+")), functionDecl(hasOverloadedOperatorName("-"))); EXPECT_FALSE(testStructuralMatch(t)); @@ -544,7 +544,7 @@ auto t = makeDecls( "struct X { virtual void f(); }; void X::f() { }", "struct X { virtual void f() { }; };", - Lang_CXX, + Lang_CXX03, functionDecl(allOf(hasName("f"), isDefinition()))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -553,7 +553,7 @@ auto t = makeDecls( "struct X { virtual void f(); }; void X::f() { }", "struct X { void f(); }; void X::f() { }", - Lang_CXX, + Lang_CXX03, functionDecl(allOf(hasName("f"), isDefinition()))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -570,7 +570,7 @@ auto t = makeDecls( "struct A{ };", "struct B{ };", - Lang_CXX, + Lang_CXX03, cxxRecordDecl(hasName("A")), cxxRecordDecl(hasName("B"))); EXPECT_FALSE(testStructuralMatch(t)); @@ -580,7 +580,7 @@ auto t = makeNamedDecls( "struct foo{ int x; };", "struct foo{ char x; };", - Lang_CXX); + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -589,7 +589,7 @@ auto t = makeNamedDecls( "struct foo{ int x(); };", "struct foo{ char x(); };", - Lang_CXX); + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -597,7 +597,7 @@ auto t = makeNamedDecls( "struct A{ }; struct foo: A { };", "struct B{ }; struct foo: B { };", - Lang_CXX); + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -605,7 +605,7 @@ auto t = makeNamedDecls( "struct A{ }; struct foo: A { };", "struct A{ }; struct foo: virtual A { };", - Lang_CXX); + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -614,7 +614,7 @@ auto t = makeNamedDecls( "struct A{ }; struct foo: public A { };", "struct A{ }; struct foo: private A { };", - Lang_CXX); + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -627,7 +627,7 @@ int a; }; )"; - auto t = makeNamedDecls(Code, Code, Lang_CXX); + auto t = makeNamedDecls(Code, Code, Lang_CXX03); EXPECT_TRUE(testStructuralMatch(t)); } @@ -643,7 +643,7 @@ } entry1; }; )", - "", Lang_C); + "", Lang_C99); auto *TU = get<0>(t); auto *Entry0 = FirstDeclMatcher().match(TU, fieldDecl(hasName("entry0"))); @@ -670,7 +670,7 @@ }; }; )", - "", Lang_C); + "", Lang_C99); auto *TU = get<0>(t); auto *A = FirstDeclMatcher().match( TU, indirectFieldDecl(hasName("a"))); @@ -702,7 +702,7 @@ struct { int a; }; }; )", - Lang_C); + Lang_C99); auto *TU = get<0>(t); auto *A = FirstDeclMatcher().match( @@ -742,7 +742,7 @@ } entry1; }; )"; - auto t = makeTuDecls(Code, Code, Lang_C); + auto t = makeTuDecls(Code, Code, Lang_C99); auto *FromTU = get<0>(t); auto *Entry1 = @@ -769,7 +769,7 @@ auto t = makeDecls( "struct A { };", "template struct A { };", - Lang_CXX, + Lang_CXX03, cxxRecordDecl(hasName("A"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -856,7 +856,7 @@ 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); + Lang_CXX03); EXPECT_FALSE(testStructuralMatch(t)); } @@ -911,19 +911,19 @@ 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)); } @@ -973,7 +973,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 +1004,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 +1112,7 @@ void f(); }; )", - Lang_CXX, + Lang_CXX03, functionTemplateDecl(hasName("f"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1141,7 +1141,7 @@ void f(); }; )", - Lang_CXX, + Lang_CXX03, functionTemplateDecl(hasName("f"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1167,7 +1167,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -1194,7 +1194,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1220,7 +1220,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_TRUE(testStructuralMatch(t)); } @@ -1247,7 +1247,7 @@ // Explicit instantiation with UNqualified name. template struct Primary; )", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1272,7 +1272,7 @@ template struct Primary; } )", - Lang_CXX, + Lang_CXX03, classTemplateSpecializationDecl(hasName("Primary"))); EXPECT_FALSE(testStructuralMatch(t)); } @@ -1306,7 +1306,7 @@ class B {}; void x(A, B); )", - Lang_CXX); + Lang_CXX03); StructuralEquivalenceContext Ctx( get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), @@ -1343,7 +1343,7 @@ friend void y(B *); }; )", - Lang_CXX); + Lang_CXX03); StructuralEquivalenceContext Ctx( get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), @@ -1382,7 +1382,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,7 +52,7 @@ 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; } @@ -88,7 +88,7 @@ static std::vector &allConfigs() { static std::vector all_configs = []() { std::vector all_configs; - for (TestLanguage lang : {Lang_C, Lang_C89, Lang_CXX, Lang_CXX11, + for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11, Lang_CXX14, Lang_CXX17, Lang_CXX2a}) { TestClangConfig config; config.Language = lang;