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 = TSW_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 @@ -45,11 +45,7 @@ }; /// 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 TypeSpecifiersPipe { TSP_unspecified, Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -262,12 +262,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; @@ -435,16 +429,16 @@ : StorageClassSpec(SCS_unspecified), ThreadStorageClassSpec(TSCS_unspecified), SCS_extern_in_linkage_spec(false), TypeSpecWidth(TSW_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), - TypeQualifiers(TQ_unspecified), - FS_inline_specified(false), FS_forceinline_specified(false), - FS_virtual_specified(false), FS_noreturn_specified(false), - Friend_specified(false), ConstexprSpecifier(CSK_unspecified), - FS_explicit_specifier(), Attrs(attrFactory), writtenBS(), - ObjCQualifiers(nullptr) {} + TypeQualifiers(TQ_unspecified), FS_inline_specified(false), + FS_forceinline_specified(false), FS_virtual_specified(false), + FS_noreturn_specified(false), Friend_specified(false), + ConstexprSpecifier(CSK_unspecified), FS_explicit_specifier(), + Attrs(attrFactory), writtenBS(), ObjCQualifiers(nullptr) {} // storage-class-specifier SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; } @@ -478,7 +472,9 @@ // type-specifier TSW getTypeSpecWidth() const { return (TSW)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; } @@ -540,7 +536,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(DeclSpec::TSW W); static const char *getSpecifierName(DeclSpec::SCS S); @@ -628,7 +624,7 @@ return getTypeSpecType() != DeclSpec::TST_unspecified || getTypeSpecWidth() != DeclSpec::TSW_unspecified || getTypeSpecComplex() != DeclSpec::TSC_unspecified || - getTypeSpecSign() != DeclSpec::TSS_unspecified; + getTypeSpecSign() != TypeSpecifierSign::Unspecified; } /// Return a bitmask of which flavors of specifiers this @@ -663,8 +659,8 @@ unsigned &DiagID, 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 @@ 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 @@ -2193,10 +2193,10 @@ DS.SetTypeSpecWidth(DeclSpec::TSW_longlong, Loc, PrevSpec, DiagID, 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 @@ -521,12 +521,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!"); } @@ -705,12 +707,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; } @@ -1089,7 +1090,7 @@ } void DeclSpec::SaveWrittenBuiltinSpecs() { - writtenBS.Sign = getTypeSpecSign(); + writtenBS.Sign = TypeSpecSign; writtenBS.Width = getTypeSpecWidth(); writtenBS.Type = getTypeSpecType(); // Search the list of attributes for the presence of a mode attribute. @@ -1111,9 +1112,8 @@ // If decltype(auto) is used, no other type specifiers are permitted. if (TypeSpecType == TST_decltype_auto && - (TypeSpecWidth != TSW_unspecified || - TypeSpecComplex != TSC_unspecified || - TypeSpecSign != TSS_unspecified || + (TypeSpecWidth != TSW_unspecified || TypeSpecComplex != TSC_unspecified || + getTypeSpecSign() != TypeSpecifierSign::Unspecified || TypeAltiVecVector || TypeAltiVecPixel || TypeAltiVecBool || TypeQualifiers)) { const unsigned NumLocs = 9; @@ -1134,7 +1134,7 @@ } TypeSpecWidth = TSW_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) @@ -1146,9 +1146,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 @@ -1181,7 +1181,7 @@ // Elements of vector bool are interpreted as unsigned. (PIM 2.1) if ((TypeSpecType == TST_char) || (TypeSpecType == TST_int) || (TypeSpecType == TST_int128) || (TypeSpecWidth != TSW_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. @@ -1216,7 +1216,7 @@ if (TypeAltiVecPixel) { //TODO: perform validation TypeSpecType = TST_int; - TypeSpecSign = TSS_unsigned; + TypeSpecSign = static_cast(TypeSpecifierSign::Unsigned); TypeSpecWidth = TSW_short; TypeSpecOwned = false; } @@ -1226,7 +1226,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 && @@ -1235,7 +1235,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 DeclSpec::TSW_unspecified: Result = Context.IntTy; break; case DeclSpec::TSW_short: Result = Context.ShortTy; break; @@ -1446,8 +1446,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); @@ -1469,7 +1470,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()) @@ -1492,7 +1493,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()) @@ -1505,7 +1506,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; @@ -5867,7 +5868,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() != TSW_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(TL.getWrittenWidthSpec()); Record.push_back(TL.hasModeAttr()); }