diff options
author | Faisal Vali <faisalv@yahoo.com> | 2018-01-01 18:23:28 +0000 |
---|---|---|
committer | Faisal Vali <faisalv@yahoo.com> | 2018-01-01 18:23:28 +0000 |
commit | 1ae65827b5b1c280e1db04f7d609a92ddf40e0a9 (patch) | |
tree | 530a1e50551df595ab705b45a0f28fa51bc790c6 /include | |
parent | 5f6d6d73da77174428971d53d68524da45e467c3 (diff) |
Again reverting an attempt to convert the DeclSpec enums into scoped enums.
- reverts r321622, r321625, and r321626.
- the use of bit-fields is still resulting in warnings - even though we can use static-asserts to harden the code and ensure the bit-fields are wide enough. The bots still complain of warnings being seen.
- to silence the warnings requires specifying the bit-fields with the underlying enum type (as opposed to the enum type itself), which then requires lots of unnecessary static casts of each enumerator within DeclSpec to the underlying-type, which even though could be seen as implementation details, it does hamper readability - and given the additional litterings, makes me question the value of the change.
So in short - I give up (for now at least).
Sorry about the noise.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321628 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Type.h | 4 | ||||
-rw-r--r-- | include/clang/AST/TypeLoc.h | 23 | ||||
-rw-r--r-- | include/clang/Basic/Specifiers.h | 74 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 9 | ||||
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 88 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 33 |
6 files changed, 108 insertions, 123 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index cd71bef9c5..882878bb7e 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(TypeSpecifierType TypeSpec); + static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned 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(TypeSpecifierType TypeSpec); + static TagTypeKind getTagTypeKindForTypeSpec(unsigned 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 cdfb740f6b..b805160a27 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -598,43 +598,43 @@ public: if (needsExtraLocalData()) return static_cast<TypeSpecifierSign>(getWrittenBuiltinSpecs().Sign); else - return TypeSpecifierSign::TSS_unspecified; + return TSS_unspecified; } bool hasWrittenSignSpec() const { - return getWrittenSignSpec() != TypeSpecifierSign::TSS_unspecified; + return getWrittenSignSpec() != TSS_unspecified; } void setWrittenSignSpec(TypeSpecifierSign written) { if (needsExtraLocalData()) - getWrittenBuiltinSpecs().Sign = static_cast<unsigned char>(written); + getWrittenBuiltinSpecs().Sign = written; } TypeSpecifierWidth getWrittenWidthSpec() const { if (needsExtraLocalData()) return static_cast<TypeSpecifierWidth>(getWrittenBuiltinSpecs().Width); else - return TypeSpecifierWidth::TSW_unspecified; + return TSW_unspecified; } bool hasWrittenWidthSpec() const { - return getWrittenWidthSpec() != TypeSpecifierWidth::TSW_unspecified; + return getWrittenWidthSpec() != TSW_unspecified; } void setWrittenWidthSpec(TypeSpecifierWidth written) { if (needsExtraLocalData()) - getWrittenBuiltinSpecs().Width = static_cast<unsigned char>(written); + getWrittenBuiltinSpecs().Width = written; } TypeSpecifierType getWrittenTypeSpec() const; bool hasWrittenTypeSpec() const { - return getWrittenTypeSpec() != TypeSpecifierType::TST_unspecified; + return getWrittenTypeSpec() != TST_unspecified; } void setWrittenTypeSpec(TypeSpecifierType written) { if (needsExtraLocalData()) - getWrittenBuiltinSpecs().Type = static_cast<unsigned char>(written); + getWrittenBuiltinSpecs().Type = written; } bool hasModeAttr() const { @@ -653,10 +653,9 @@ public: setBuiltinLoc(Loc); if (needsExtraLocalData()) { WrittenBuiltinSpecs &wbs = getWrittenBuiltinSpecs(); - wbs.Sign = static_cast<unsigned char>(TypeSpecifierSign::TSS_unspecified); - wbs.Width = - static_cast<unsigned char>(TypeSpecifierWidth::TSW_unspecified); - wbs.Type = static_cast<unsigned char>(TypeSpecifierType::TST_unspecified); + wbs.Sign = TSS_unspecified; + wbs.Width = TSW_unspecified; + wbs.Type = TST_unspecified; wbs.ModeAttr = false; } } diff --git a/include/clang/Basic/Specifiers.h b/include/clang/Basic/Specifiers.h index be12af9eaa..377534baab 100644 --- a/include/clang/Basic/Specifiers.h +++ b/include/clang/Basic/Specifiers.h @@ -22,87 +22,71 @@ namespace clang { /// \brief Specifies the width of a type, e.g., short, long, or long long. - enum class TypeSpecifierWidth : unsigned char { + enum TypeSpecifierWidth { TSW_unspecified, TSW_short, TSW_long, - TSW_longlong // This must be the last enumerator (see struct - // WrittenBuiltinSpecs below prior to reordering). + TSW_longlong }; /// \brief Specifies the signedness of a type, e.g., signed or unsigned. - enum class TypeSpecifierSign : unsigned char { + enum TypeSpecifierSign { TSS_unspecified, TSS_signed, - TSS_unsigned // This must be the last enumerator (see struct - // WrittenBuiltinSpecs below prior to reordering). + TSS_unsigned }; - + enum TypeSpecifiersPipe { TSP_unspecified, TSP_pipe }; /// \brief Specifies the kind of type. - enum class TypeSpecifierType : unsigned char { + enum TypeSpecifierType { TST_unspecified, TST_void, TST_char, - TST_wchar, // C++ wchar_t - TST_char16, // C++11 char16_t - TST_char32, // C++11 char32_t + TST_wchar, // C++ wchar_t + TST_char16, // C++11 char16_t + TST_char32, // C++11 char32_t TST_int, TST_int128, - TST_half, // OpenCL half, ARM NEON __fp16 - TST_Float16, // C11 extension ISO/IEC TS 18661-3 + TST_half, // OpenCL half, ARM NEON __fp16 + TST_Float16, // C11 extension ISO/IEC TS 18661-3 TST_float, TST_double, TST_float128, - TST_bool, // _Bool - TST_decimal32, // _Decimal32 - TST_decimal64, // _Decimal64 - TST_decimal128, // _Decimal128 + TST_bool, // _Bool + TST_decimal32, // _Decimal32 + TST_decimal64, // _Decimal64 + TST_decimal128, // _Decimal128 TST_enum, TST_union, TST_struct, - TST_class, // C++ class type - TST_interface, // C++ (Microsoft-specific) __interface type - TST_typename, // Typedef, C++ class-name or enum name, etc. + TST_class, // C++ class type + TST_interface, // C++ (Microsoft-specific) __interface type + TST_typename, // Typedef, C++ class-name or enum name, etc. TST_typeofType, TST_typeofExpr, - TST_decltype, // C++11 decltype - TST_underlyingType, // __underlying_type for C++11 - TST_auto, // C++11 auto - TST_decltype_auto, // C++1y decltype(auto) - TST_auto_type, // __auto_type extension - TST_unknown_anytype, // __unknown_anytype extension - TST_atomic, // C11 _Atomic + TST_decltype, // C++11 decltype + TST_underlyingType, // __underlying_type for C++11 + TST_auto, // C++11 auto + TST_decltype_auto, // C++1y decltype(auto) + TST_auto_type, // __auto_type extension + TST_unknown_anytype, // __unknown_anytype extension + TST_atomic, // C11 _Atomic #define GENERIC_IMAGE_TYPE(ImgType, Id) TST_##ImgType##_t, // OpenCL image types #include "clang/Basic/OpenCLImageTypes.def" - TST_error // erroneous type -- Additionally, this must be the last - // enumerator (see struct WrittenBuiltinSpecs below prior to - // reordering). + TST_error // erroneous type }; /// \brief Structure that packs information about the type specifiers that /// were written in a particular type specifier sequence. struct WrittenBuiltinSpecs { - - static_assert(static_cast<unsigned int>(TypeSpecifierType::TST_error) < - (1 << 6), - "Type bitfield not wide enough for TST"); - /*DeclSpec::TST*/ unsigned Type : 6; - - static_assert(static_cast<unsigned int>(TypeSpecifierSign::TSS_unsigned) < - (1 << 2), - "Type bitfield not wide enough for TSS"); - /*DeclSpec::TSS*/ unsigned Sign : 2; - - static_assert(static_cast<unsigned int>(TypeSpecifierWidth::TSW_longlong) < - (1 << 2), - "Type bitfield not wide enough for TSW"); + 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; - unsigned ModeAttr : 1; }; diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 800c73ee8f..a606d78530 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -828,8 +828,7 @@ private: }; /// \brief Consume any extra semi-colons until the end of the line. - void ConsumeExtraSemi(ExtraSemiKind Kind, - TypeSpecifierType TST = TypeSpecifierType::TST_unspecified); + void ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST = TST_unspecified); /// Return false if the next token is an identifier. An 'expected identifier' /// error is emitted otherwise. @@ -1976,7 +1975,7 @@ private: const ParsedTemplateInfo &TemplateInfo, AccessSpecifier AS, DeclSpecContext DSC); void ParseEnumBody(SourceLocation StartLoc, Decl *TagDecl); - void ParseStructUnionBody(SourceLocation StartLoc, TypeSpecifierType TagType, + void ParseStructUnionBody(SourceLocation StartLoc, unsigned TagType, Decl *TagDecl); void ParseStructDeclaration( @@ -2576,12 +2575,12 @@ private: ParsedAttributesWithRange &Attributes); void SkipCXXMemberSpecification(SourceLocation StartLoc, SourceLocation AttrFixitLoc, - TypeSpecifierType TagType, + unsigned TagType, Decl *TagDecl); void ParseCXXMemberSpecification(SourceLocation StartLoc, SourceLocation AttrFixitLoc, ParsedAttributesWithRange &Attrs, - TypeSpecifierType TagType, + unsigned 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 1940a3caa3..2e7411337b 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 = 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; + 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; enum TSC { TSC_unspecified, @@ -263,48 +263,48 @@ public: // Import type specifier sign enumeration and constants. typedef TypeSpecifierSign TSS; - static const TSS TSS_unspecified = TypeSpecifierSign::TSS_unspecified; - static const TSS TSS_signed = TypeSpecifierSign::TSS_signed; - static const TSS TSS_unsigned = TypeSpecifierSign::TSS_unsigned; + 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 = 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; + 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; #define GENERIC_IMAGE_TYPE(ImgType, Id) \ - static const TST TST_##ImgType##_t = TypeSpecifierType::TST_##ImgType##_t; + static const TST TST_##ImgType##_t = clang::TST_##ImgType##_t; #include "clang/Basic/OpenCLImageTypes.def" - static const TST TST_error = TypeSpecifierType::TST_error; + static const TST TST_error = clang::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*/TypeSpecifierWidth TypeSpecWidth : 2; + /*TSW*/unsigned TypeSpecWidth : 2; /*TSC*/unsigned TypeSpecComplex : 2; - /*TSS*/TypeSpecifierSign TypeSpecSign : 2; - /*TST*/TypeSpecifierType TypeSpecType : 6; + /*TSS*/unsigned TypeSpecSign : 2; + /*TST*/unsigned 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 d03827a12a..9cbe8e5cd6 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, TypeSpecifierType TagSpec, TagUseKind TUK, + Decl *ActOnTag(Scope *S, unsigned 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, - TypeSpecifierType TagSpec, SourceLocation TagLoc, + unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists); TypeResult ActOnDependentTag(Scope *S, - TypeSpecifierType TagSpec, + unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, @@ -6123,14 +6123,17 @@ public: ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid); - 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); + 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); TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, @@ -6201,7 +6204,7 @@ public: TemplateTy &Template, bool AllowInjectedClassName = false); DeclResult - ActOnClassTemplateSpecialization(Scope *S, TypeSpecifierType TagSpec, TagUseKind TUK, + ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, @@ -6244,7 +6247,7 @@ public: ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, - TypeSpecifierType TagSpec, + unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, @@ -6258,7 +6261,7 @@ public: ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, - TypeSpecifierType TagSpec, + unsigned TagSpec, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, @@ -10152,7 +10155,7 @@ public: SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement); void CodeCompletePostfixExpression(Scope *S, ExprResult LHS); - void CodeCompleteTag(Scope *S, TypeSpecifierType TagSpec); + void CodeCompleteTag(Scope *S, unsigned TagSpec); void CodeCompleteTypeQualifiers(DeclSpec &DS); void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS = nullptr); |