Skip to content

Commit

Permalink
Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Browse files Browse the repository at this point in the history
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".

I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.

Reviewers: shafik, hlopko

Reviewed By: hlopko

Subscribers: jfb, martong, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81000
  • Loading branch information
gribozavr committed Jun 2, 2020
1 parent aa3a85c commit d559185
Show file tree
Hide file tree
Showing 9 changed files with 759 additions and 867 deletions.
6 changes: 3 additions & 3 deletions clang/include/clang/Testing/CommandLineArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
namespace clang {

enum TestLanguage {
Lang_C,
Lang_C89,
Lang_CXX,
Lang_C99,
Lang_CXX03,
Lang_CXX11,
Lang_CXX14,
Lang_CXX17,
Lang_CXX2a,
Lang_CXX20,
Lang_OpenCL,
Lang_OBJCXX
};
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/Testing/CommandLineArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ std::vector<std::string> getCommandLineArgsForTesting(TestLanguage Lang) {
std::vector<std::string> 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"};
Expand All @@ -33,8 +33,8 @@ std::vector<std::string> getCommandLineArgsForTesting(TestLanguage Lang) {
case Lang_CXX17:
Args = {"-std=c++17", "-frtti"};
break;
case Lang_CXX2a:
Args = {"-std=c++2a", "-frtti"};
case Lang_CXX20:
Args = {"-std=c++20", "-frtti"};
break;
case Lang_OBJCXX:
Args = {"-x", "objective-c++", "-frtti"};
Expand Down
70 changes: 35 additions & 35 deletions clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {

void
TypedTest_PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition() {
Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX);
Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX03);
auto *FromD = FirstDeclMatcher<DeclTy>().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<DeclTy>().match(ToTU, getPattern()), 1u);
Expand All @@ -197,11 +197,11 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

void TypedTest_DefinitionShouldBeImportedAsADefinition() {
Decl *FromTU = getTuDecl(getDefinition(), Lang_CXX);
Decl *FromTU = getTuDecl(getDefinition(), Lang_CXX03);
auto *FromD = FirstDeclMatcher<DeclTy>().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<DeclTy>().match(ToTU, getPattern()), 1u);
Expand All @@ -213,14 +213,14 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

void TypedTest_ImportPrototypeAfterImportedPrototype() {
Decl *FromTU = getTuDecl(getPrototype() + getPrototype(), Lang_CXX);
Decl *FromTU = getTuDecl(getPrototype() + getPrototype(), Lang_CXX03);
auto *From0 = FirstDeclMatcher<DeclTy>().match(FromTU, getPattern());
auto *From1 = LastDeclMatcher<DeclTy>().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<DeclTy>().match(ToTU, getPattern()), 2u);
Expand All @@ -235,14 +235,14 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

void TypedTest_ImportDefinitionAfterImportedPrototype() {
Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX);
Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX03);
auto *FromProto = FirstDeclMatcher<DeclTy>().match(FromTU, getPattern());
auto *FromDef = LastDeclMatcher<DeclTy>().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<DeclTy>().match(ToTU, getPattern()), 2u);
Expand All @@ -257,14 +257,14 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

void TypedTest_ImportPrototypeAfterImportedDefinition() {
Decl *FromTU = getTuDecl(getDefinition() + getPrototype(), Lang_CXX);
Decl *FromTU = getTuDecl(getDefinition() + getPrototype(), Lang_CXX03);
auto *FromDef = FirstDeclMatcher<DeclTy>().match(FromTU, getPattern());
auto *FromProto = LastDeclMatcher<DeclTy>().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<DeclTy>().match(ToTU, getPattern()), 2u);
Expand All @@ -279,15 +279,15 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

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<DeclTy>().match(FromTU0, getPattern());
auto *From1 = FirstDeclMatcher<DeclTy>().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<DeclTy>().match(ToTU, getPattern()), 2u);
Expand All @@ -302,15 +302,15 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

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<DeclTy>().match(FromTU0, getPattern());
auto *From1 = FirstDeclMatcher<DeclTy>().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);
Expand All @@ -324,16 +324,16 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

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<DeclTy>().match(FromTUDef, getPattern());
auto *FromProto =
FirstDeclMatcher<DeclTy>().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);
Expand All @@ -349,16 +349,16 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

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<DeclTy>().match(FromTUProto, getPattern());
auto *FromDef = FirstDeclMatcher<DeclTy>().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);
Expand All @@ -374,12 +374,12 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {
}

void TypedTest_WholeRedeclChainIsImportedAtOnce() {
Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX);
Decl *FromTU = getTuDecl(getPrototype() + getDefinition(), Lang_CXX03);
auto *FromD = // Definition
LastDeclMatcher<DeclTy>().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.
Expand All @@ -389,15 +389,15 @@ struct RedeclChain : ASTImporterOptionSpecificTestBase {

void TypedTest_ImportPrototypeThenProtoAndDefinition() {
{
Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX, "input0.cc");
Decl *FromTU = getTuDecl(getPrototype(), Lang_CXX03, "input0.cc");
auto *FromD = FirstDeclMatcher<DeclTy>().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<DeclTy>().match(FromTU, getPattern());
Import(FromD, Lang_CXX);
Import(FromD, Lang_CXX03);
}

Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
Expand Down
20 changes: 10 additions & 10 deletions clang/unittests/AST/ASTImporterODRStrategiesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ struct Function {
BindableMatcher<Decl> getPattern() {
return functionDecl(hasName("X"), unless(isImplicit()));
}
TestLanguage getLang() { return Lang_C; }
TestLanguage getLang() { return Lang_C99; }
};

struct Typedef {
using DeclTy = TypedefNameDecl;
static constexpr auto *Definition = "typedef int X;";
static constexpr auto *ConflictingDefinition = "typedef double X;";
BindableMatcher<Decl> getPattern() { return typedefNameDecl(hasName("X")); }
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

struct TypedefAlias {
Expand All @@ -61,7 +61,7 @@ struct Enum {
static constexpr auto *Definition = "enum X { a, b };";
static constexpr auto *ConflictingDefinition = "enum X { a, b, c };";
BindableMatcher<Decl> getPattern() { return enumDecl(hasName("X")); }
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

struct EnumClass {
Expand All @@ -77,7 +77,7 @@ struct EnumConstant {
static constexpr auto *Definition = "enum E { X = 0 };";
static constexpr auto *ConflictingDefinition = "enum E { X = 1 };";
BindableMatcher<Decl> getPattern() { return enumConstantDecl(hasName("X")); }
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

struct Class {
Expand All @@ -88,7 +88,7 @@ struct Class {
BindableMatcher<Decl> getPattern() {
return cxxRecordDecl(hasName("X"), unless(isImplicit()));
}
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

struct Variable {
Expand All @@ -98,7 +98,7 @@ struct Variable {
static constexpr auto *Definition = "int X;";
static constexpr auto *ConflictingDefinition = "float X;";
BindableMatcher<Decl> getPattern() { return varDecl(hasName("X")); }
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

struct ClassTemplate {
Expand All @@ -112,7 +112,7 @@ struct ClassTemplate {
BindableMatcher<Decl> getPattern() {
return classTemplateDecl(hasName("X"), unless(isImplicit()));
}
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

struct FunctionTemplate {
Expand All @@ -133,7 +133,7 @@ struct FunctionTemplate {
}
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<Decl, VarTemplateDecl>
Expand Down Expand Up @@ -175,7 +175,7 @@ struct ClassTemplateSpec {
BindableMatcher<Decl> getPattern() {
return classTemplateSpecializationDecl(hasName("X"), unless(isImplicit()));
}
TestLanguage getLang() { return Lang_CXX; }
TestLanguage getLang() { return Lang_CXX03; }
};

// Function template specializations are all "full" specializations.
Expand Down Expand Up @@ -208,7 +208,7 @@ struct FunctionTemplateSpec {
}
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<
Expand Down
Loading

0 comments on commit d559185

Please sign in to comment.