Index: clang/include/clang/AST/TypeLoc.h =================================================================== --- clang/include/clang/AST/TypeLoc.h +++ clang/include/clang/AST/TypeLoc.h @@ -603,16 +603,16 @@ if (needsExtraLocalData()) return static_cast(getWrittenBuiltinSpecs().Sign); else - return TSS_unspecified; + return TypeSpecifierSign::Unspecified; } bool hasWrittenSignSpec() const { - return getWrittenSignSpec() != TSS_unspecified; + return getWrittenSignSpec() != TypeSpecifierSign::Unspecified; } void setWrittenSignSpec(TypeSpecifierSign written) { if (needsExtraLocalData()) - getWrittenBuiltinSpecs().Sign = written; + getWrittenBuiltinSpecs().Sign = static_cast(written); } TypeSpecifierWidth getWrittenWidthSpec() const { @@ -658,7 +658,7 @@ setBuiltinLoc(Loc); if (needsExtraLocalData()) { WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); - wbs.Sign = TSS_unspecified; + wbs.Sign = static_cast(TypeSpecifierSign::Unspecified); wbs.Width = static_cast(TypeSpecifierWidth::Unspecified); wbs.Type = TST_unspecified; wbs.ModeAttr = false; Index: clang/include/clang/Basic/Specifiers.h =================================================================== --- clang/include/clang/Basic/Specifiers.h +++ clang/include/clang/Basic/Specifiers.h @@ -40,11 +40,7 @@ enum class TypeSpecifierWidth { Unspecified, Short, Long, LongLong }; /// Specifies the signedness of a type, e.g., signed or unsigned. - enum TypeSpecifierSign { - TSS_unspecified, - TSS_signed, - TSS_unsigned - }; + enum class TypeSpecifierSign { Unspecified, Signed, Unsigned }; enum class TypeSpecifiersPipe { Unspecified, Pipe }; Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -255,12 +255,6 @@ TSC_complex }; - // Import type specifier sign enumeration and constants. - typedef TypeSpecifierSign TSS; - static const TSS TSS_unspecified = clang::TSS_unspecified; - static const TSS TSS_signed = clang::TSS_signed; - static const TSS TSS_unsigned = clang::TSS_unsigned; - // Import type specifier type enumeration and constants. typedef TypeSpecifierType TST; static const TST TST_unspecified = clang::TST_unspecified; @@ -429,7 +423,8 @@ ThreadStorageClassSpec(TSCS_unspecified), SCS_extern_in_linkage_spec(false), TypeSpecWidth(static_cast(TypeSpecifierWidth::Unspecified)), - TypeSpecComplex(TSC_unspecified), TypeSpecSign(TSS_unspecified), + TypeSpecComplex(TSC_unspecified), + TypeSpecSign(static_cast(TypeSpecifierSign::Unspecified)), TypeSpecType(TST_unspecified), TypeAltiVecVector(false), TypeAltiVecPixel(false), TypeAltiVecBool(false), TypeSpecOwned(false), TypeSpecPipe(false), TypeSpecSat(false), ConstrainedAuto(false), @@ -473,7 +468,9 @@ return static_cast(TypeSpecWidth); } TSC getTypeSpecComplex() const { return (TSC)TypeSpecComplex; } - TSS getTypeSpecSign() const { return (TSS)TypeSpecSign; } + TypeSpecifierSign getTypeSpecSign() const { + return static_cast(TypeSpecSign); + } TST getTypeSpecType() const { return (TST)TypeSpecType; } bool isTypeAltiVecVector() const { return TypeAltiVecVector; } bool isTypeAltiVecPixel() const { return TypeAltiVecPixel; } @@ -535,7 +532,7 @@ static const char *getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy); static const char *getSpecifierName(DeclSpec::TQ Q); - static const char *getSpecifierName(DeclSpec::TSS S); + static const char *getSpecifierName(TypeSpecifierSign S); static const char *getSpecifierName(DeclSpec::TSC C); static const char *getSpecifierName(TypeSpecifierWidth W); static const char *getSpecifierName(DeclSpec::SCS S); @@ -623,7 +620,7 @@ return getTypeSpecType() != DeclSpec::TST_unspecified || getTypeSpecWidth() != TypeSpecifierWidth::Unspecified || getTypeSpecComplex() != DeclSpec::TSC_unspecified || - getTypeSpecSign() != DeclSpec::TSS_unspecified; + getTypeSpecSign() != TypeSpecifierSign::Unspecified; } /// Return a bitmask of which flavors of specifiers this @@ -659,8 +656,8 @@ const PrintingPolicy &Policy); bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); - bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID); + bool SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, + const char *&PrevSpec, unsigned &DiagID); bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -3706,11 +3706,11 @@ PrevSpec, DiagID, Policy); break; case tok::kw_signed: - isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec, - DiagID); + isInvalid = + DS.SetTypeSpecSign(TypeSpecifierSign::Signed, Loc, PrevSpec, DiagID); break; case tok::kw_unsigned: - isInvalid = DS.SetTypeSpecSign(DeclSpec::TSS_unsigned, Loc, PrevSpec, + isInvalid = DS.SetTypeSpecSign(TypeSpecifierSign::Unsigned, Loc, PrevSpec, DiagID); break; case tok::kw__Complex: Index: clang/lib/Parse/ParseExprCXX.cpp =================================================================== --- clang/lib/Parse/ParseExprCXX.cpp +++ clang/lib/Parse/ParseExprCXX.cpp @@ -2196,10 +2196,10 @@ Policy); break; case tok::kw_signed: - DS.SetTypeSpecSign(DeclSpec::TSS_signed, Loc, PrevSpec, DiagID); + DS.SetTypeSpecSign(TypeSpecifierSign::Signed, Loc, PrevSpec, DiagID); break; case tok::kw_unsigned: - DS.SetTypeSpecSign(DeclSpec::TSS_unsigned, Loc, PrevSpec, DiagID); + DS.SetTypeSpecSign(TypeSpecifierSign::Unsigned, Loc, PrevSpec, DiagID); break; case tok::kw_void: DS.SetTypeSpecType(DeclSpec::TST_void, Loc, PrevSpec, DiagID, Policy); Index: clang/lib/Sema/DeclSpec.cpp =================================================================== --- clang/lib/Sema/DeclSpec.cpp +++ clang/lib/Sema/DeclSpec.cpp @@ -525,12 +525,14 @@ llvm_unreachable("Unknown typespec!"); } - -const char *DeclSpec::getSpecifierName(TSS S) { +const char *DeclSpec::getSpecifierName(TypeSpecifierSign S) { switch (S) { - case TSS_unspecified: return "unspecified"; - case TSS_signed: return "signed"; - case TSS_unsigned: return "unsigned"; + case TypeSpecifierSign::Unspecified: + return "unspecified"; + case TypeSpecifierSign::Signed: + return "signed"; + case TypeSpecifierSign::Unsigned: + return "unsigned"; } llvm_unreachable("Unknown typespec!"); } @@ -709,12 +711,11 @@ return false; } -bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc, - const char *&PrevSpec, - unsigned &DiagID) { - if (TypeSpecSign != TSS_unspecified) - return BadSpecifier(S, (TSS)TypeSpecSign, PrevSpec, DiagID); - TypeSpecSign = S; +bool DeclSpec::SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, + const char *&PrevSpec, unsigned &DiagID) { + if (getTypeSpecSign() != TypeSpecifierSign::Unspecified) + return BadSpecifier(S, getTypeSpecSign(), PrevSpec, DiagID); + TypeSpecSign = static_cast(S); TSSLoc = Loc; return false; } @@ -1094,7 +1095,7 @@ void DeclSpec::SaveWrittenBuiltinSpecs() { writtenBS.Sign = getTypeSpecSign(); - writtenBS.Width = TypeSpecWidth; + writtenBS.Width = getTypeSpecWidth(); writtenBS.Type = getTypeSpecType(); // Search the list of attributes for the presence of a mode attribute. writtenBS.ModeAttr = getAttributes().hasAttribute(ParsedAttr::AT_Mode); @@ -1116,7 +1117,8 @@ // If decltype(auto) is used, no other type specifiers are permitted. if (TypeSpecType == TST_decltype_auto && (getTypeSpecWidth() != TypeSpecifierWidth::Unspecified || - TypeSpecComplex != TSC_unspecified || TypeSpecSign != TSS_unspecified || + TypeSpecComplex != TSC_unspecified || + getTypeSpecSign() != TypeSpecifierSign::Unspecified || TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool || TypeQualifiers)) { const unsigned NumLocs = 9; @@ -1137,7 +1139,7 @@ } TypeSpecWidth = static_cast(TypeSpecifierWidth::Unspecified); TypeSpecComplex = TSC_unspecified; - TypeSpecSign = TSS_unspecified; + TypeSpecSign = static_cast(TypeSpecifierSign::Unspecified); TypeAltiVecVector = TypeAltiVecPixel = TypeAltiVecBool = false; TypeQualifiers = 0; S.Diag(TSTLoc, diag::err_decltype_auto_cannot_be_combined) @@ -1149,9 +1151,9 @@ if (TypeAltiVecVector) { if (TypeAltiVecBool) { // Sign specifiers are not allowed with vector bool. (PIM 2.1) - if (TypeSpecSign != TSS_unspecified) { + if (getTypeSpecSign() != TypeSpecifierSign::Unspecified) { S.Diag(TSSLoc, diag::err_invalid_vector_bool_decl_spec) - << getSpecifierName((TSS)TypeSpecSign); + << getSpecifierName(getTypeSpecSign()); } // Only char/int are valid with vector bool prior to Power10. // Power10 adds instructions that produce vector bool data @@ -1186,7 +1188,7 @@ if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) || (TypeSpecType == TST_int128) || (getTypeSpecWidth() != TypeSpecifierWidth::Unspecified)) - TypeSpecSign = TSS_unsigned; + TypeSpecSign = static_cast(TypeSpecifierSign::Unsigned); } else if (TypeSpecType == TST_double) { // vector long double and vector long long double are never allowed. // vector double is OK for Power7 and later, and ZVector. @@ -1222,7 +1224,7 @@ if (TypeAltiVecPixel) { //TODO: perform validation TypeSpecType = TST_int; - TypeSpecSign = TSS_unsigned; + TypeSpecSign = static_cast(TypeSpecifierSign::Unsigned); TypeSpecWidth = static_cast(TypeSpecifierWidth::Short); TypeSpecOwned = false; } @@ -1232,7 +1234,7 @@ TypeSpecType == TST_accum || TypeSpecType == TST_fract; // signed/unsigned are only valid with int/char/wchar_t/_Accum. - if (TypeSpecSign != TSS_unspecified) { + if (getTypeSpecSign() != TypeSpecifierSign::Unspecified) { if (TypeSpecType == TST_unspecified) TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int. else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 && @@ -1241,7 +1243,7 @@ S.Diag(TSSLoc, diag::err_invalid_sign_spec) << getSpecifierName((TST)TypeSpecType, Policy); // signed double -> double. - TypeSpecSign = TSS_unspecified; + TypeSpecSign = static_cast(TypeSpecifierSign::Unspecified); } } Index: clang/lib/Sema/SemaCodeComplete.cpp =================================================================== --- clang/lib/Sema/SemaCodeComplete.cpp +++ clang/lib/Sema/SemaCodeComplete.cpp @@ -4256,7 +4256,7 @@ DS.getParsedSpecifiers() == DeclSpec::PQ_TypeSpecifier && DS.getTypeSpecType() == DeclSpec::TST_typename && DS.getTypeSpecComplex() == DeclSpec::TSC_unspecified && - DS.getTypeSpecSign() == DeclSpec::TSS_unspecified && + DS.getTypeSpecSign() == TypeSpecifierSign::Unspecified && !DS.isTypeAltiVecVector() && S && (S->getFlags() & Scope::DeclScope) != 0 && (S->getFlags() & (Scope::ClassScope | Scope::TemplateParamScope | Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -1300,27 +1300,27 @@ Result = Context.VoidTy; break; case DeclSpec::TST_char: - if (DS.getTypeSpecSign() == DeclSpec::TSS_unspecified) + if (DS.getTypeSpecSign() == TypeSpecifierSign::Unspecified) Result = Context.CharTy; - else if (DS.getTypeSpecSign() == DeclSpec::TSS_signed) + else if (DS.getTypeSpecSign() == TypeSpecifierSign::Signed) Result = Context.SignedCharTy; else { - assert(DS.getTypeSpecSign() == DeclSpec::TSS_unsigned && + assert(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned && "Unknown TSS value"); Result = Context.UnsignedCharTy; } break; case DeclSpec::TST_wchar: - if (DS.getTypeSpecSign() == DeclSpec::TSS_unspecified) + if (DS.getTypeSpecSign() == TypeSpecifierSign::Unspecified) Result = Context.WCharTy; - else if (DS.getTypeSpecSign() == DeclSpec::TSS_signed) { + else if (DS.getTypeSpecSign() == TypeSpecifierSign::Signed) { S.Diag(DS.getTypeSpecSignLoc(), diag::ext_wchar_t_sign_spec) << DS.getSpecifierName(DS.getTypeSpecType(), Context.getPrintingPolicy()); Result = Context.getSignedWCharType(); } else { - assert(DS.getTypeSpecSign() == DeclSpec::TSS_unsigned && - "Unknown TSS value"); + assert(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned && + "Unknown TSS value"); S.Diag(DS.getTypeSpecSignLoc(), diag::ext_wchar_t_sign_spec) << DS.getSpecifierName(DS.getTypeSpecType(), Context.getPrintingPolicy()); @@ -1328,19 +1328,19 @@ } break; case DeclSpec::TST_char8: - assert(DS.getTypeSpecSign() == DeclSpec::TSS_unspecified && - "Unknown TSS value"); - Result = Context.Char8Ty; + assert(DS.getTypeSpecSign() == TypeSpecifierSign::Unspecified && + "Unknown TSS value"); + Result = Context.Char8Ty; break; case DeclSpec::TST_char16: - assert(DS.getTypeSpecSign() == DeclSpec::TSS_unspecified && - "Unknown TSS value"); - Result = Context.Char16Ty; + assert(DS.getTypeSpecSign() == TypeSpecifierSign::Unspecified && + "Unknown TSS value"); + Result = Context.Char16Ty; break; case DeclSpec::TST_char32: - assert(DS.getTypeSpecSign() == DeclSpec::TSS_unspecified && - "Unknown TSS value"); - Result = Context.Char32Ty; + assert(DS.getTypeSpecSign() == TypeSpecifierSign::Unspecified && + "Unknown TSS value"); + Result = Context.Char32Ty; break; case DeclSpec::TST_unspecified: // If this is a missing declspec in a block literal return context, then it @@ -1401,7 +1401,7 @@ LLVM_FALLTHROUGH; case DeclSpec::TST_int: { - if (DS.getTypeSpecSign() != DeclSpec::TSS_unsigned) { + if (DS.getTypeSpecSign() != TypeSpecifierSign::Unsigned) { switch (DS.getTypeSpecWidth()) { case TypeSpecifierWidth::Unspecified: Result = Context.IntTy; @@ -1458,8 +1458,9 @@ if (!S.Context.getTargetInfo().hasExtIntType()) S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "_ExtInt"; - Result = S.BuildExtIntType(DS.getTypeSpecSign() == TSS_unsigned, - DS.getRepAsExpr(), DS.getBeginLoc()); + Result = + S.BuildExtIntType(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned, + DS.getRepAsExpr(), DS.getBeginLoc()); if (Result.isNull()) { Result = Context.IntTy; declarator.setInvalidType(true); @@ -1481,7 +1482,7 @@ llvm_unreachable("Unable to specify long long as _Accum width"); } - if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned) + if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned) Result = Context.getCorrespondingUnsignedType(Result); if (DS.isTypeSpecSat()) @@ -1504,7 +1505,7 @@ llvm_unreachable("Unable to specify long long as _Fract width"); } - if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned) + if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned) Result = Context.getCorrespondingUnsignedType(Result); if (DS.isTypeSpecSat()) @@ -1517,7 +1518,7 @@ !(S.getLangOpts().OpenMP && S.getLangOpts().OpenMPIsDevice)) S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "__int128"; - if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned) + if (DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned) Result = Context.UnsignedInt128Ty; else Result = Context.Int128Ty; @@ -5881,7 +5882,7 @@ // Set info for the written builtin specifiers. TL.getWrittenBuiltinSpecs() = DS.getWrittenBuiltinSpecs(); // Try to have a meaningful source location. - if (TL.getWrittenSignSpec() != TSS_unspecified) + if (TL.getWrittenSignSpec() != TypeSpecifierSign::Unspecified) TL.expandBuiltinRange(DS.getTypeSpecSignLoc()); if (TL.getWrittenWidthSpec() != TypeSpecifierWidth::Unspecified) TL.expandBuiltinRange(DS.getTypeSpecWidthRange()); Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -6457,7 +6457,7 @@ TL.setBuiltinLoc(readSourceLocation()); if (TL.needsExtraLocalData()) { TL.setWrittenTypeSpec(static_cast(Reader.readInt())); - TL.setWrittenSignSpec(static_cast(Reader.readInt())); + TL.setWrittenSignSpec(static_cast(Reader.readInt())); TL.setWrittenWidthSpec(static_cast(Reader.readInt())); TL.setModeAttr(Reader.readInt()); } Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -198,7 +198,7 @@ Record.AddSourceLocation(TL.getBuiltinLoc()); if (TL.needsExtraLocalData()) { Record.push_back(TL.getWrittenTypeSpec()); - Record.push_back(TL.getWrittenSignSpec()); + Record.push_back(static_cast(TL.getWrittenSignSpec())); Record.push_back(static_cast(TL.getWrittenWidthSpec())); Record.push_back(TL.hasModeAttr()); }