diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 882878bb7e1e7660003ed842196fcb4c6cc42815..cd71bef9c5cd64101ec4fa013bb359c9aae59702 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -4747,11 +4747,11 @@ public: } /// Converts a type specifier (DeclSpec::TST) into an elaborated type keyword. - static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec); + static ElaboratedTypeKeyword getKeywordForTypeSpec(TypeSpecifierType TypeSpec); /// Converts a type specifier (DeclSpec::TST) into a tag type kind. /// It is an error to provide a type specifier which *isn't* a tag kind here. - static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec); + static TagTypeKind getTagTypeKindForTypeSpec(TypeSpecifierType TypeSpec); /// Converts a TagTypeKind into an elaborated type keyword. static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag); diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index b805160a278071b20297f9eb333b95cc3478d801..dca4fcffcb05d2f88799bfd5d15308d321c8fa49 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -598,11 +598,11 @@ public: if (needsExtraLocalData()) return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); else - return TSS_unspecified; + return TypeSpecifierSign::TSS_unspecified; } bool hasWrittenSignSpec() const { - return getWrittenSignSpec() != TSS_unspecified; + return getWrittenSignSpec() != TypeSpecifierSign::TSS_unspecified; } void setWrittenSignSpec(TypeSpecifierSign written) { @@ -614,11 +614,11 @@ public: if (needsExtraLocalData()) return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); else - return TSW_unspecified; + return TypeSpecifierWidth::TSW_unspecified; } bool hasWrittenWidthSpec() const { - return getWrittenWidthSpec() != TSW_unspecified; + return getWrittenWidthSpec() != TypeSpecifierWidth::TSW_unspecified; } void setWrittenWidthSpec(TypeSpecifierWidth written) { @@ -629,7 +629,7 @@ public: TypeSpecifierType getWrittenTypeSpec() const; bool hasWrittenTypeSpec() const { - return getWrittenTypeSpec() != TST_unspecified; + return getWrittenTypeSpec() != TypeSpecifierType::TST_unspecified; } void setWrittenTypeSpec(TypeSpecifierType written) { @@ -653,9 +653,9 @@ public: setBuiltinLoc(Loc); if (needsExtraLocalData()) { WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); - wbs.Sign = TSS_unspecified; - wbs.Width = TSW_unspecified; - wbs.Type = TST_unspecified; + wbs.Sign = TypeSpecifierSign::TSS_unspecified; + wbs.Width = TypeSpecifierWidth::TSW_unspecified; + wbs.Type = TypeSpecifierType::TST_unspecified; wbs.ModeAttr = false; } } diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h index 377534baab06ba1994e6a3d61a4f82e84a0327c6..79792ee3f45080bdcad86698823092e23cf27d91 100644 --- a/include/clang/Basic/Specifiers.h +++ b/include/clang/Basic/Specifiers.h @@ -22,7 +22,7 @@ namespace clang { /// \brief Specifies the width of a type, e.g., short, long, or long long. - enum TypeSpecifierWidth { + enum class TypeSpecifierWidth { TSW_unspecified, TSW_short, TSW_long, @@ -30,7 +30,7 @@ namespace clang { }; /// \brief Specifies the signedness of a type, e.g., signed or unsigned. - enum TypeSpecifierSign { + enum class TypeSpecifierSign { TSS_unspecified, TSS_signed, TSS_unsigned @@ -42,7 +42,7 @@ namespace clang { }; /// \brief Specifies the kind of type. - enum TypeSpecifierType { + enum class TypeSpecifierType { TST_unspecified, TST_void, TST_char, @@ -83,10 +83,11 @@ namespace clang { /// \brief Structure that packs information about the type specifiers that /// were written in a particular type specifier sequence. struct WrittenBuiltinSpecs { - static_assert(TST_error < 1 << 6, "Type bitfield not wide enough for TST"); - /*DeclSpec::TST*/ unsigned Type : 6; - /*DeclSpec::TSS*/ unsigned Sign : 2; - /*DeclSpec::TSW*/ unsigned Width : 2; + static_assert(static_cast<int>(TypeSpecifierType::TST_error) < (1 << 6), + "Type bitfield not wide enough for TST"); + /*DeclSpec::TST*/ TypeSpecifierType Type : 6; + /*DeclSpec::TSS*/ TypeSpecifierSign Sign : 2; + /*DeclSpec::TSW*/ TypeSpecifierWidth Width : 2; unsigned ModeAttr : 1; }; diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index a606d785304a5fb424c4c2f7e407694b6e9427a6..800c73ee8f546ee0da73bcecb3868eb2af23e4c2 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -828,7 +828,8 @@ private: }; /// \brief Consume any extra semi-colons until the end of the line. - void ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST = TST_unspecified); + void ConsumeExtraSemi(ExtraSemiKind Kind, + TypeSpecifierType TST = TypeSpecifierType::TST_unspecified); /// Return false if the next token is an identifier. An 'expected identifier' /// error is emitted otherwise. @@ -1975,7 +1976,7 @@ private: const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, DeclSpecContext DSC); void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl); - void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType, + void ParseStructUnionBody(SourceLocation StartLoc, TypeSpecifierType TagType, Decl *TagDecl); void ParseStructDeclaration( @@ -2575,12 +2576,12 @@ private: ParsedAttributesWithRange &Attributes); void SkipCXXMemberSpecification(SourceLocation StartLoc, SourceLocation AttrFixitLoc, - unsigned TagType, + TypeSpecifierType TagType, Decl *TagDecl); void ParseCXXMemberSpecification(SourceLocation StartLoc, SourceLocation AttrFixitLoc, ParsedAttributesWithRange &Attrs, - unsigned TagType, + TypeSpecifierType TagType, Decl *TagDecl); ExprResult ParseCXXMemberInitializer(Decl *D, bool IsFunction, SourceLocation &EqualLoc); diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 2e7411337bfcb73070a041c3d9c469f78e77112a..1940a3caa3795a821643d6726d328ddf856fdedd 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -250,10 +250,10 @@ public: // Import type specifier width enumeration and constants. typedef TypeSpecifierWidth TSW; - static const TSW TSW_unspecified = clang::TSW_unspecified; - static const TSW TSW_short = clang::TSW_short; - static const TSW TSW_long = clang::TSW_long; - static const TSW TSW_longlong = clang::TSW_longlong; + static const TSW TSW_unspecified = TypeSpecifierWidth::TSW_unspecified; + static const TSW TSW_short = TypeSpecifierWidth::TSW_short; + static const TSW TSW_long = TypeSpecifierWidth::TSW_long; + static const TSW TSW_longlong = TypeSpecifierWidth::TSW_longlong; enum TSC { TSC_unspecified, @@ -263,48 +263,48 @@ public: // 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; + static const TSS TSS_unspecified = TypeSpecifierSign::TSS_unspecified; + static const TSS TSS_signed = TypeSpecifierSign::TSS_signed; + static const TSS TSS_unsigned = TypeSpecifierSign::TSS_unsigned; // Import type specifier type enumeration and constants. typedef TypeSpecifierType TST; - static const TST TST_unspecified = clang::TST_unspecified; - static const TST TST_void = clang::TST_void; - static const TST TST_char = clang::TST_char; - static const TST TST_wchar = clang::TST_wchar; - static const TST TST_char16 = clang::TST_char16; - static const TST TST_char32 = clang::TST_char32; - static const TST TST_int = clang::TST_int; - static const TST TST_int128 = clang::TST_int128; - static const TST TST_half = clang::TST_half; - static const TST TST_float = clang::TST_float; - static const TST TST_double = clang::TST_double; - static const TST TST_float16 = clang::TST_Float16; - static const TST TST_float128 = clang::TST_float128; - static const TST TST_bool = clang::TST_bool; - static const TST TST_decimal32 = clang::TST_decimal32; - static const TST TST_decimal64 = clang::TST_decimal64; - static const TST TST_decimal128 = clang::TST_decimal128; - static const TST TST_enum = clang::TST_enum; - static const TST TST_union = clang::TST_union; - static const TST TST_struct = clang::TST_struct; - static const TST TST_interface = clang::TST_interface; - static const TST TST_class = clang::TST_class; - static const TST TST_typename = clang::TST_typename; - static const TST TST_typeofType = clang::TST_typeofType; - static const TST TST_typeofExpr = clang::TST_typeofExpr; - static const TST TST_decltype = clang::TST_decltype; - static const TST TST_decltype_auto = clang::TST_decltype_auto; - static const TST TST_underlyingType = clang::TST_underlyingType; - static const TST TST_auto = clang::TST_auto; - static const TST TST_auto_type = clang::TST_auto_type; - static const TST TST_unknown_anytype = clang::TST_unknown_anytype; - static const TST TST_atomic = clang::TST_atomic; + static const TST TST_unspecified = TypeSpecifierType::TST_unspecified; + static const TST TST_void = TypeSpecifierType::TST_void; + static const TST TST_char = TypeSpecifierType::TST_char; + static const TST TST_wchar = TypeSpecifierType::TST_wchar; + static const TST TST_char16 = TypeSpecifierType::TST_char16; + static const TST TST_char32 = TypeSpecifierType::TST_char32; + static const TST TST_int = TypeSpecifierType::TST_int; + static const TST TST_int128 = TypeSpecifierType::TST_int128; + static const TST TST_half = TypeSpecifierType::TST_half; + static const TST TST_float = TypeSpecifierType::TST_float; + static const TST TST_double = TypeSpecifierType::TST_double; + static const TST TST_float16 = TypeSpecifierType::TST_Float16; + static const TST TST_float128 = TypeSpecifierType::TST_float128; + static const TST TST_bool = TypeSpecifierType::TST_bool; + static const TST TST_decimal32 = TypeSpecifierType::TST_decimal32; + static const TST TST_decimal64 = TypeSpecifierType::TST_decimal64; + static const TST TST_decimal128 = TypeSpecifierType::TST_decimal128; + static const TST TST_enum = TypeSpecifierType::TST_enum; + static const TST TST_union = TypeSpecifierType::TST_union; + static const TST TST_struct = TypeSpecifierType::TST_struct; + static const TST TST_interface = TypeSpecifierType::TST_interface; + static const TST TST_class = TypeSpecifierType::TST_class; + static const TST TST_typename = TypeSpecifierType::TST_typename; + static const TST TST_typeofType = TypeSpecifierType::TST_typeofType; + static const TST TST_typeofExpr = TypeSpecifierType::TST_typeofExpr; + static const TST TST_decltype = TypeSpecifierType::TST_decltype; + static const TST TST_decltype_auto = TypeSpecifierType::TST_decltype_auto; + static const TST TST_underlyingType = TypeSpecifierType::TST_underlyingType; + static const TST TST_auto = TypeSpecifierType::TST_auto; + static const TST TST_auto_type = TypeSpecifierType::TST_auto_type; + static const TST TST_unknown_anytype = TypeSpecifierType::TST_unknown_anytype; + static const TST TST_atomic = TypeSpecifierType::TST_atomic; #define GENERIC_IMAGE_TYPE(ImgType, Id) \ - static const TST TST_##ImgType##_t = clang::TST_##ImgType##_t; + static const TST TST_##ImgType##_t = TypeSpecifierType::TST_##ImgType##_t; #include "clang/Basic/OpenCLImageTypes.def" - static const TST TST_error = clang::TST_error; + static const TST TST_error = TypeSpecifierType::TST_error; // type-qualifiers enum TQ { // NOTE: These flags must be kept in sync with Qualifiers::TQ. @@ -335,10 +335,10 @@ private: unsigned SCS_extern_in_linkage_spec : 1; // type-specifier - /*TSW*/unsigned TypeSpecWidth : 2; + /*TSW*/TypeSpecifierWidth TypeSpecWidth : 2; /*TSC*/unsigned TypeSpecComplex : 2; - /*TSS*/unsigned TypeSpecSign : 2; - /*TST*/unsigned TypeSpecType : 6; + /*TSS*/TypeSpecifierSign TypeSpecSign : 2; + /*TST*/TypeSpecifierType TypeSpecType : 6; unsigned TypeAltiVecVector : 1; unsigned TypeAltiVecPixel : 1; unsigned TypeAltiVecBool : 1; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 9cbe8e5cd63ef4d8f79d74edd99ed6f309b83af9..d03827a12afc5c3fe581ff30b3c670bd6ce81232 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2182,7 +2182,7 @@ public: TUK_Friend // Friend declaration: 'friend struct foo;' }; - Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, + Decl *ActOnTag(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, @@ -2193,14 +2193,14 @@ public: SkipBodyInfo *SkipBody = nullptr); Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, - unsigned TagSpec, SourceLocation TagLoc, + TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists); TypeResult ActOnDependentTag(Scope *S, - unsigned TagSpec, + TypeSpecifierType TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, @@ -6123,17 +6123,14 @@ public: ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid); - DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, - SourceLocation KWLoc, CXXScopeSpec &SS, - IdentifierInfo *Name, SourceLocation NameLoc, - AttributeList *Attr, - TemplateParameterList *TemplateParams, - AccessSpecifier AS, - SourceLocation ModulePrivateLoc, - SourceLocation FriendLoc, - unsigned NumOuterTemplateParamLists, - TemplateParameterList **OuterTemplateParamLists, - SkipBodyInfo *SkipBody = nullptr); + DeclResult CheckClassTemplate( + Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, SourceLocation KWLoc, + CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, + AttributeList *Attr, TemplateParameterList *TemplateParams, + AccessSpecifier AS, SourceLocation ModulePrivateLoc, + SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, + TemplateParameterList **OuterTemplateParamLists, + SkipBodyInfo *SkipBody = nullptr); TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, @@ -6204,7 +6201,7 @@ public: TemplateTy &Template, bool AllowInjectedClassName = false); DeclResult - ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, + ActOnClassTemplateSpecialization(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, @@ -6247,7 +6244,7 @@ public: ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, - unsigned TagSpec, + TypeSpecifierType TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, @@ -6261,7 +6258,7 @@ public: ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, - unsigned TagSpec, + TypeSpecifierType TagSpec, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, @@ -10155,7 +10152,7 @@ public: SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement); void CodeCompletePostfixExpression(Scope *S, ExprResult LHS); - void CodeCompleteTag(Scope *S, unsigned TagSpec); + void CodeCompleteTag(Scope *S, TypeSpecifierType TagSpec); void CodeCompleteTypeQualifiers(DeclSpec &DS); void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS = nullptr); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 38f2a16fa16ff327d0a900b0a04462361b9a2cce..dc370e3d59e8a110ebf77e6def29faa3cb7b634a 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -2436,29 +2436,41 @@ bool Type::isSpecifierType() const { } ElaboratedTypeKeyword -TypeWithKeyword::getKeywordForTypeSpec(unsigned TypeSpec) { +TypeWithKeyword::getKeywordForTypeSpec(TypeSpecifierType TypeSpec) { switch (TypeSpec) { - default: return ETK_None; - case TST_typename: return ETK_Typename; - case TST_class: return ETK_Class; - case TST_struct: return ETK_Struct; - case TST_interface: return ETK_Interface; - case TST_union: return ETK_Union; - case TST_enum: return ETK_Enum; + default: + return ETK_None; + case TypeSpecifierType::TST_typename: + return ETK_Typename; + case TypeSpecifierType::TST_class: + return ETK_Class; + case TypeSpecifierType::TST_struct: + return ETK_Struct; + case TypeSpecifierType::TST_interface: + return ETK_Interface; + case TypeSpecifierType::TST_union: + return ETK_Union; + case TypeSpecifierType::TST_enum: + return ETK_Enum; } } TagTypeKind -TypeWithKeyword::getTagTypeKindForTypeSpec(unsigned TypeSpec) { - switch(TypeSpec) { - case TST_class: return TTK_Class; - case TST_struct: return TTK_Struct; - case TST_interface: return TTK_Interface; - case TST_union: return TTK_Union; - case TST_enum: return TTK_Enum; +TypeWithKeyword::getTagTypeKindForTypeSpec(TypeSpecifierType TypeSpec) { + switch (TypeSpec) { + default: + llvm_unreachable("Type specifier is not a tag type kind."); + case TypeSpecifierType::TST_class: + return TTK_Class; + case TypeSpecifierType::TST_struct: + return TTK_Struct; + case TypeSpecifierType::TST_interface: + return TTK_Interface; + case TypeSpecifierType::TST_union: + return TTK_Union; + case TypeSpecifierType::TST_enum: + return TTK_Enum; } - - llvm_unreachable("Type specifier is not a tag type kind."); } ElaboratedTypeKeyword diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 127e18439b8e01703b60320d7639ccaab3036abf..37cb8e29ea5b0a7e4652cc569b42978509c2f777 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3139,7 +3139,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // static const bool __is_signed; // // then treat __is_signed as an identifier rather than as a keyword. - if (DS.getTypeSpecType() == TST_bool && + if (DS.getTypeSpecType() == TypeSpecifierType::TST_bool && DS.getTypeQualifiers() == DeclSpec::TQ_const && DS.getStorageClassSpec() == DeclSpec::SCS_static) TryKeywordIdentFallback(true); @@ -3614,7 +3614,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, break; #include "clang/Basic/OpenCLImageTypes.def" case tok::kw___unknown_anytype: - isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc, + isInvalid = DS.SetTypeSpecType(TypeSpecifierType::TST_unknown_anytype, Loc, PrevSpec, DiagID, Policy); break; @@ -3888,7 +3888,7 @@ void Parser::ParseStructDeclaration( /// [OBC] '@' 'defs' '(' class-name ')' /// void Parser::ParseStructUnionBody(SourceLocation RecordLoc, - unsigned TagType, Decl *TagDecl) { + TypeSpecifierType TagType, Decl *TagDecl) { PrettyDeclStackTraceEntry CrashInfo(Actions, TagDecl, RecordLoc, "parsing struct/union body"); assert(!getLangOpts().CPlusPlus && "C++ declarations not supported"); @@ -5527,7 +5527,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) { NextToken().is(tok::r_paren) && !D.hasGroupingParens() && !Actions.containsUnexpandedParameterPacks(D) && - D.getDeclSpec().getTypeSpecType() != TST_auto)) { + D.getDeclSpec().getTypeSpecType() != TypeSpecifierType::TST_auto)) { SourceLocation EllipsisLoc = ConsumeToken(); if (isPtrOperatorToken(Tok.getKind(), getLangOpts(), D.getContext())) { // The ellipsis was put in the wrong place. Recover, and explain to @@ -6107,7 +6107,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D, LocalEndLoc = EndLoc; if (getLangOpts().CPlusPlus11 && Tok.is(tok::arrow)) { Diag(Tok, diag::warn_cxx98_compat_trailing_return_type); - if (D.getDeclSpec().getTypeSpecType() == TST_auto) + if (D.getDeclSpec().getTypeSpecType() == TypeSpecifierType::TST_auto) StartLoc = D.getDeclSpec().getTypeSpecTypeLoc(); LocalEndLoc = Tok.getLocation(); SourceRange Range; diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 68b73ca1d25f294961a4754f576d57a442087279..8953eef1d7e03084cb2e75d97dcca20d20140959 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1011,10 +1011,12 @@ void Parser::AnnotateExistingDecltypeSpecifier(const DeclSpec& DS, PP.EnterToken(Tok); Tok.setKind(tok::annot_decltype); - setExprAnnotation(Tok, - DS.getTypeSpecType() == TST_decltype ? DS.getRepAsExpr() : - DS.getTypeSpecType() == TST_decltype_auto ? ExprResult() : - ExprError()); + setExprAnnotation(Tok, DS.getTypeSpecType() == TypeSpecifierType::TST_decltype + ? DS.getRepAsExpr() + : DS.getTypeSpecType() == + TypeSpecifierType::TST_decltype_auto + ? ExprResult() + : ExprError()); Tok.setAnnotationEndLoc(EndLoc); Tok.setLocation(StartLoc); PP.AnnotateCachedTokens(Tok); @@ -1194,8 +1196,8 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, const char *PrevSpec = nullptr; unsigned DiagID; - DS.SetTypeSpecType(TST_typename, IdLoc, PrevSpec, DiagID, Type, - Actions.getASTContext().getPrintingPolicy()); + DS.SetTypeSpecType(TypeSpecifierType::TST_typename, IdLoc, PrevSpec, DiagID, + Type, Actions.getASTContext().getPrintingPolicy()); Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); return Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); @@ -2952,7 +2954,8 @@ ExprResult Parser::ParseCXXMemberInitializer(Decl *D, bool IsFunction, void Parser::SkipCXXMemberSpecification(SourceLocation RecordLoc, SourceLocation AttrFixitLoc, - unsigned TagType, Decl *TagDecl) { + TypeSpecifierType TagType, + Decl *TagDecl) { // Skip the optional 'final' keyword. if (getLangOpts().CPlusPlus && Tok.is(tok::identifier)) { assert(isCXX11FinalKeyword() && "not a class definition"); @@ -3104,11 +3107,12 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas( void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc, SourceLocation AttrFixitLoc, ParsedAttributesWithRange &Attrs, - unsigned TagType, Decl *TagDecl) { + TypeSpecifierType TagType, + Decl *TagDecl) { assert((TagType == DeclSpec::TST_struct || - TagType == DeclSpec::TST_interface || - TagType == DeclSpec::TST_union || - TagType == DeclSpec::TST_class) && "Invalid TagType!"); + TagType == DeclSpec::TST_interface || + TagType == DeclSpec::TST_union || TagType == DeclSpec::TST_class) && + "Invalid TagType!"); PrettyDeclStackTraceEntry CrashInfo(Actions, TagDecl, RecordLoc, "parsing struct/union/class body"); diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 1b8865edb79aac11d9cdd19d1286debf6c1852be..057b4e6cd5b61ce82e1ecf8a79b02bd8d80bfd1d 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -997,9 +997,10 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, DS.SetRangeEnd(ILoc); const char *PrevSpec = nullptr; unsigned DiagID; - DS.SetTypeSpecType(TST_typename, ILoc, PrevSpec, DiagID, Typ, + DS.SetTypeSpecType(TypeSpecifierType::TST_typename, ILoc, PrevSpec, + DiagID, Typ, Actions.getASTContext().getPrintingPolicy()); - + Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); @@ -1205,8 +1206,8 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, const char *PrevSpec = nullptr; unsigned DiagID; - DS.SetTypeSpecType(TST_typename, Tok.getAnnotationEndLoc(), - PrevSpec, DiagID, Type, + DS.SetTypeSpecType(TypeSpecifierType::TST_typename, + Tok.getAnnotationEndLoc(), PrevSpec, DiagID, Type, Actions.getASTContext().getPrintingPolicy()); Declarator DeclaratorInfo(DS, DeclaratorContext::TypeNameContext); diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 554ab24b02e1c0b8872934d8fcfb5ab3a261fff0..3e2f4fd589115a7b2d099403752d0bedf8445617 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -1551,7 +1551,7 @@ Parser::ParseCXXPseudoDestructor(Expr *Base, SourceLocation OpLoc, if (Tok.is(tok::kw_decltype) && !FirstTypeName.isValid() && SS.isEmpty()) { DeclSpec DS(AttrFactory); ParseDecltypeSpecifier(DS); - if (DS.getTypeSpecType() == TST_error) + if (DS.getTypeSpecType() == TypeSpecifierType::TST_error) return ExprError(); return Actions.ActOnPseudoDestructorExpr(getCurScope(), Base, OpLoc, OpKind, TildeLoc, DS); diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 688376ca28e69f92c6336cbb91f0644b132e11d7..4a29ee1b9a43f7277e744e3baae2c3e25b53eb20 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1699,8 +1699,9 @@ void Parser::parseObjCTypeArgsOrProtocolQualifiers( DeclSpec DS(AttrFactory); const char *prevSpec = nullptr; unsigned diagID; - DS.SetTypeSpecType(TST_typename, identifierLocs[i], prevSpec, diagID, - typeArg, Actions.getASTContext().getPrintingPolicy()); + DS.SetTypeSpecType(TypeSpecifierType::TST_typename, identifierLocs[i], + prevSpec, diagID, typeArg, + Actions.getASTContext().getPrintingPolicy()); // Form a declarator to turn this into a type. Declarator D(DS, DeclaratorContext::TypeNameContext); diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index a6f966eda1b99e7af8d5596338c851b805bb34a3..9e33b3470dd2331474aee33f39a593ecf27ec73e 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -174,7 +174,7 @@ bool Parser::ExpectAndConsumeSemi(unsigned DiagID) { return ExpectAndConsume(tok::semi, DiagID); } -void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST) { +void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, TypeSpecifierType TST) { if (!Tok.is(tok::semi)) return; bool HadMultipleSemis = false; diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 2fad5a18ba6bcf81e686b3d88a259ae1212aa0fd..69266933d6d683dd906005708fc9a6e11c9ceaaa 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -324,51 +324,52 @@ bool Declarator::isDeclarationOfFunction() const { } switch (DS.getTypeSpecType()) { - case TST_atomic: - case TST_auto: - case TST_auto_type: - case TST_bool: - case TST_char: - case TST_char16: - case TST_char32: - case TST_class: - case TST_decimal128: - case TST_decimal32: - case TST_decimal64: - case TST_double: - case TST_Float16: - case TST_float128: - case TST_enum: - case TST_error: - case TST_float: - case TST_half: - case TST_int: - case TST_int128: - case TST_struct: - case TST_interface: - case TST_union: - case TST_unknown_anytype: - case TST_unspecified: - case TST_void: - case TST_wchar: -#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t: + case TypeSpecifierType::TST_atomic: + case TypeSpecifierType::TST_auto: + case TypeSpecifierType::TST_auto_type: + case TypeSpecifierType::TST_bool: + case TypeSpecifierType::TST_char: + case TypeSpecifierType::TST_char16: + case TypeSpecifierType::TST_char32: + case TypeSpecifierType::TST_class: + case TypeSpecifierType::TST_decimal128: + case TypeSpecifierType::TST_decimal32: + case TypeSpecifierType::TST_decimal64: + case TypeSpecifierType::TST_double: + case TypeSpecifierType::TST_Float16: + case TypeSpecifierType::TST_float128: + case TypeSpecifierType::TST_enum: + case TypeSpecifierType::TST_error: + case TypeSpecifierType::TST_float: + case TypeSpecifierType::TST_half: + case TypeSpecifierType::TST_int: + case TypeSpecifierType::TST_int128: + case TypeSpecifierType::TST_struct: + case TypeSpecifierType::TST_interface: + case TypeSpecifierType::TST_union: + case TypeSpecifierType::TST_unknown_anytype: + case TypeSpecifierType::TST_unspecified: + case TypeSpecifierType::TST_void: + case TypeSpecifierType::TST_wchar: +#define GENERIC_IMAGE_TYPE(ImgType, Id) \ + case TypeSpecifierType::TST_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" return false; - case TST_decltype_auto: + case TypeSpecifierType::TST_decltype_auto: // This must have an initializer, so can't be a function declaration, // even if the initializer has function type. return false; - case TST_decltype: - case TST_typeofExpr: + case TypeSpecifierType::TST_decltype: + case TypeSpecifierType::TST_typeofExpr: if (Expr *E = DS.getRepAsExpr()) return E->getType()->isFunctionType(); return false; - case TST_underlyingType: - case TST_typename: - case TST_typeofType: { + case TypeSpecifierType::TST_underlyingType: + case TypeSpecifierType::TST_typename: + case TypeSpecifierType::TST_typeofType: { QualType QT = DS.getRepAsType().get(); if (QT.isNull()) return false; @@ -498,7 +499,8 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T, case DeclSpec::TST_unspecified: return "unspecified"; case DeclSpec::TST_void: return "void"; case DeclSpec::TST_char: return "char"; - case DeclSpec::TST_wchar: return Policy.MSWChar ? "__wchar_t" : "wchar_t"; + case DeclSpec::TST_wchar: + return Policy.MSWChar ? "__wchar_t" : "wchar_t"; case DeclSpec::TST_char16: return "char16_t"; case DeclSpec::TST_char32: return "char32_t"; case DeclSpec::TST_int: return "int"; diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 2acc896d53d71bd2d29997984b6706df66fd45a5..2433cf2d970f486d97df74597528b02ecc9499ab 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -4088,7 +4088,7 @@ void Sema::CodeCompleteObjCClassPropertyRefExpr(Scope *S, Results.data(), Results.size()); } -void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) { +void Sema::CodeCompleteTag(Scope *S, TypeSpecifierType TagSpec) { if (!CodeCompleter) return; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 743f4bb5e8228af9911bfd6ea847ac803fd0b7f3..b5c990939c5414994480e083d094bb24d9746077 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -12786,11 +12786,11 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T, // class type (or enum type) for linkage purposes only. // We need to check whether the type was declared in the declaration. switch (D.getDeclSpec().getTypeSpecType()) { - case TST_enum: - case TST_struct: - case TST_interface: - case TST_union: - case TST_class: { + case TypeSpecifierType::TST_enum: + case TypeSpecifierType::TST_struct: + case TypeSpecifierType::TST_interface: + case TypeSpecifierType::TST_union: + case TypeSpecifierType::TST_class: { TagDecl *tagFromDeclSpec = cast<TagDecl>(D.getDeclSpec().getRepAsDecl()); setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD); break; @@ -13074,7 +13074,7 @@ static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, /// /// \param SkipBody If non-null, will be set to indicate if the caller should /// skip the definition of this tag and treat it as if it were a declaration. -Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, +Decl *Sema::ActOnTag(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index ceded02e3940d75e38cd4229ad05a862860077f3..ca108491943896058f3e772f3d73c7abce435fdf 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -3775,9 +3775,9 @@ Sema::BuildMemInitializer(Decl *ConstructorD, if (TemplateTypeTy) { BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo); - } else if (DS.getTypeSpecType() == TST_decltype) { + } else if (DS.getTypeSpecType() == TypeSpecifierType::TST_decltype) { BaseType = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc()); - } else if (DS.getTypeSpecType() == TST_decltype_auto) { + } else if (DS.getTypeSpecType() == TypeSpecifierType::TST_decltype_auto) { Diag(DS.getTypeSpecTypeLoc(), diag::err_decltype_auto_invalid); return true; } else { @@ -13480,11 +13480,10 @@ FriendDecl *Sema::CheckFriendTypeDecl(SourceLocation LocStart, /// Handle a friend tag declaration where the scope specifier was /// templated. Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, - unsigned TagSpec, SourceLocation TagLoc, - CXXScopeSpec &SS, + TypeSpecifierType TagSpec, + SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, - SourceLocation NameLoc, - AttributeList *Attr, + SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists) { TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec); diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 7c6af5793fc55f552f1233668d4612af2ff27a86..9cc19672eff953f8cbb27f1535a359a1646ef132 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1152,7 +1152,7 @@ static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS) { } DeclResult -Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, +Sema::CheckClassTemplate(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, @@ -7336,7 +7336,7 @@ bool Sema::CheckTemplatePartialSpecializationArgs( } DeclResult -Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, +Sema::ActOnClassTemplateSpecialization(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, @@ -8506,7 +8506,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, - unsigned TagSpec, + TypeSpecifierType TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy TemplateD, @@ -8794,7 +8794,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, - unsigned TagSpec, + TypeSpecifierType TagSpec, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, @@ -9310,7 +9310,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, } TypeResult -Sema::ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, +Sema::ActOnDependentTag(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc) { // This has to hold, because SS is expected to be defined. diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index d81837dad5085fac3a118051826e0be92a8e7bdc..7acdad5572f1efdebfc1fc6b673a9cd4c02a2287 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -791,52 +791,53 @@ Optional<unsigned> Sema::getNumArgumentsInExpansion(QualType T, bool Sema::containsUnexpandedParameterPacks(Declarator &D) { const DeclSpec &DS = D.getDeclSpec(); switch (DS.getTypeSpecType()) { - case TST_typename: - case TST_typeofType: - case TST_underlyingType: - case TST_atomic: { + case TypeSpecifierType::TST_typename: + case TypeSpecifierType::TST_typeofType: + case TypeSpecifierType::TST_underlyingType: + case TypeSpecifierType::TST_atomic: { QualType T = DS.getRepAsType().get(); if (!T.isNull() && T->containsUnexpandedParameterPack()) return true; break; } - case TST_typeofExpr: - case TST_decltype: + case TypeSpecifierType::TST_typeofExpr: + case TypeSpecifierType::TST_decltype: if (DS.getRepAsExpr() && DS.getRepAsExpr()->containsUnexpandedParameterPack()) return true; break; - case TST_unspecified: - case TST_void: - case TST_char: - case TST_wchar: - case TST_char16: - case TST_char32: - case TST_int: - case TST_int128: - case TST_half: - case TST_float: - case TST_double: - case TST_Float16: - case TST_float128: - case TST_bool: - case TST_decimal32: - case TST_decimal64: - case TST_decimal128: - case TST_enum: - case TST_union: - case TST_struct: - case TST_interface: - case TST_class: - case TST_auto: - case TST_auto_type: - case TST_decltype_auto: -#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t: + case TypeSpecifierType::TST_unspecified: + case TypeSpecifierType::TST_void: + case TypeSpecifierType::TST_char: + case TypeSpecifierType::TST_wchar: + case TypeSpecifierType::TST_char16: + case TypeSpecifierType::TST_char32: + case TypeSpecifierType::TST_int: + case TypeSpecifierType::TST_int128: + case TypeSpecifierType::TST_half: + case TypeSpecifierType::TST_float: + case TypeSpecifierType::TST_double: + case TypeSpecifierType::TST_Float16: + case TypeSpecifierType::TST_float128: + case TypeSpecifierType::TST_bool: + case TypeSpecifierType::TST_decimal32: + case TypeSpecifierType::TST_decimal64: + case TypeSpecifierType::TST_decimal128: + case TypeSpecifierType::TST_enum: + case TypeSpecifierType::TST_union: + case TypeSpecifierType::TST_struct: + case TypeSpecifierType::TST_interface: + case TypeSpecifierType::TST_class: + case TypeSpecifierType::TST_auto: + case TypeSpecifierType::TST_auto_type: + case TypeSpecifierType::TST_decltype_auto: +#define GENERIC_IMAGE_TYPE(ImgType, Id) \ + case TypeSpecifierType::TST_##ImgType##_t: #include "clang/Basic/OpenCLImageTypes.def" - case TST_unknown_anytype: - case TST_error: + case TypeSpecifierType::TST_unknown_anytype: + case TypeSpecifierType::TST_error: break; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 4dab52a9f5f44c18257036515b5f21ade5d31170..160bd146e51e197c46880351207b74836c7e45a3 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1433,8 +1433,10 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { // If the type is deprecated or unavailable, diagnose it. S.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeNameLoc()); - assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 && - DS.getTypeSpecSign() == 0 && "No qualifiers on tag names!"); + assert(DS.getTypeSpecWidth() == TypeSpecifierWidth::TSW_unspecified && + DS.getTypeSpecComplex() == 0 && + DS.getTypeSpecSign() == TypeSpecifierSign::TSS_unspecified && + "No qualifiers on tag names!"); // TypeQuals handled by caller. Result = Context.getTypeDeclType(D); @@ -1446,8 +1448,9 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { break; } case DeclSpec::TST_typename: { - assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 && - DS.getTypeSpecSign() == 0 && + assert(DS.getTypeSpecWidth() == TypeSpecifierWidth::TSW_unspecified && + DS.getTypeSpecComplex() == 0 && + DS.getTypeSpecSign() == TypeSpecifierSign::TSS_unspecified && "Can't handle qualifiers on typedef names yet!"); Result = S.GetTypeFromParser(DS.getRepAsType()); if (Result.isNull()) { @@ -5308,16 +5311,16 @@ namespace { // 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::TSS_unspecified) TL.expandBuiltinRange(DS.getTypeSpecSignLoc()); - if (TL.getWrittenWidthSpec() != TSW_unspecified) + if (TL.getWrittenWidthSpec() != TypeSpecifierWidth::TSW_unspecified) TL.expandBuiltinRange(DS.getTypeSpecWidthRange()); } } void VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { ElaboratedTypeKeyword Keyword = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType()); - if (DS.getTypeSpecType() == TST_typename) { + if (DS.getTypeSpecType() == TypeSpecifierType::TST_typename) { TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); if (TInfo) { @@ -5333,7 +5336,7 @@ namespace { Visit(TL.getNextTypeLoc().getUnqualifiedLoc()); } void VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { - assert(DS.getTypeSpecType() == TST_typename); + assert(DS.getTypeSpecType() == TypeSpecifierType::TST_typename); TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); assert(TInfo); @@ -5341,7 +5344,7 @@ namespace { } void VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc TL) { - assert(DS.getTypeSpecType() == TST_typename); + assert(DS.getTypeSpecType() == TypeSpecifierType::TST_typename); TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); assert(TInfo);