From cdc2235915bde8888291f6fd2090c6509e1b07b5 Mon Sep 17 00:00:00 2001 From: David Majnemer <david.majnemer@gmail.com> Date: Fri, 24 Jun 2016 04:05:35 +0000 Subject: [PATCH] Use the same underlying type for bitfields MSVC allocates fresh storage for consecutive bitfields with different underlying types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273646 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Attr.h | 10 +++++----- include/clang/AST/Decl.h | 20 ++++++++++---------- include/clang/AST/DeclCXX.h | 12 ++++++------ include/clang/AST/Expr.h | 2 +- include/clang/AST/ExprCXX.h | 8 ++++---- include/clang/Driver/Driver.h | 2 +- include/clang/Sema/DeclSpec.h | 10 +++++----- include/clang/Sema/Overload.h | 2 +- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h index 85d30cd55b0..a94b161a04b 100644 --- a/include/clang/AST/Attr.h +++ b/include/clang/AST/Attr.h @@ -51,11 +51,11 @@ protected: /// An index into the spelling list of an /// attribute defined in Attr.td file. unsigned SpellingListIndex : 4; - bool Inherited : 1; - bool IsPackExpansion : 1; - bool Implicit : 1; - bool IsLateParsed : 1; - bool DuplicatesAllowed : 1; + unsigned Inherited : 1; + unsigned IsPackExpansion : 1; + unsigned Implicit : 1; + unsigned IsLateParsed : 1; + unsigned DuplicatesAllowed : 1; void *operator new(size_t bytes) LLVM_NOEXCEPT { llvm_unreachable("Attrs cannot be allocated with regular 'new'."); diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 8229078b505..dbb44dfbc24 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -2270,7 +2270,7 @@ public: /// represent a member of a struct/union/class. class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> { // FIXME: This can be packed into the bitfields in Decl. - bool Mutable : 1; + unsigned Mutable : 1; mutable unsigned CachedFieldIndex : 31; /// The kinds of value we can store in InitializerOrBitWidth. @@ -2717,20 +2717,20 @@ private: /// IsCompleteDefinition - True if this is a definition ("struct foo /// {};"), false if it is a declaration ("struct foo;"). It is not /// a definition until the definition has been fully processed. - bool IsCompleteDefinition : 1; + unsigned IsCompleteDefinition : 1; protected: /// IsBeingDefined - True if this is currently being defined. - bool IsBeingDefined : 1; + unsigned IsBeingDefined : 1; private: /// IsEmbeddedInDeclarator - True if this tag declaration is /// "embedded" (i.e., defined or declared for the very first time) /// in the syntax of a declarator. - bool IsEmbeddedInDeclarator : 1; + unsigned IsEmbeddedInDeclarator : 1; /// \brief True if this tag is free standing, e.g. "struct foo;". - bool IsFreeStanding : 1; + unsigned IsFreeStanding : 1; protected: // These are used by (and only defined for) EnumDecl. @@ -2739,26 +2739,26 @@ protected: /// IsScoped - True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. - bool IsScoped : 1; + unsigned IsScoped : 1; /// IsScopedUsingClassTag - If this tag declaration is a scoped enum, /// then this is true if the scoped enum was declared using the class /// tag, false if it was declared with the struct tag. No meaning is /// associated if this tag declaration is not a scoped enum. - bool IsScopedUsingClassTag : 1; + unsigned IsScopedUsingClassTag : 1; /// IsFixed - True if this is an enumeration with fixed underlying type. Only /// possible in C++11, Microsoft extensions, or Objective C mode. - bool IsFixed : 1; + unsigned IsFixed : 1; /// \brief Indicates whether it is possible for declarations of this kind /// to have an out-of-date definition. /// /// This option is only enabled when modules are enabled. - bool MayHaveOutOfDateDef : 1; + unsigned MayHaveOutOfDateDef : 1; /// Has the full definition of this type been required by a use somewhere in /// the TU. - bool IsCompleteDefinitionRequired : 1; + unsigned IsCompleteDefinitionRequired : 1; private: SourceLocation RBraceLoc; diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index 755542c04a1..9c860f40e1b 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -165,13 +165,13 @@ class CXXBaseSpecifier { SourceLocation EllipsisLoc; /// \brief Whether this is a virtual base class or not. - bool Virtual : 1; + unsigned Virtual : 1; /// \brief Whether this is the base of a class (true) or of a struct (false). /// /// This determines the mapping from the access specifier as written in the /// source code to the access specifier used for semantic analysis. - bool BaseOfClass : 1; + unsigned BaseOfClass : 1; /// \brief Access specifier as written in the source code (may be AS_none). /// @@ -181,7 +181,7 @@ class CXXBaseSpecifier { /// \brief Whether the class contains a using declaration /// to inherit the named class's constructors. - bool InheritConstructors : 1; + unsigned InheritConstructors : 1; /// \brief The type of the base class. /// @@ -1943,15 +1943,15 @@ class CXXCtorInitializer final /// \brief If the initializee is a type, whether that type makes this /// a delegating initialization. - bool IsDelegating : 1; + unsigned IsDelegating : 1; /// \brief If the initializer is a base initializer, this keeps track /// of whether the base is virtual or not. - bool IsVirtual : 1; + unsigned IsVirtual : 1; /// \brief Whether or not the initializer is explicitly written /// in the sources. - bool IsWritten : 1; + unsigned IsWritten : 1; /// If IsWritten is true, then this number keeps track of the textual order /// of this initializer in the original sources, counting from 0; otherwise, diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 5d050b0ec65..ac77484dfe3 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -3956,7 +3956,7 @@ private: /// Whether this designated initializer used the GNU deprecated /// syntax rather than the C99 '=' syntax. - bool GNUSyntax : 1; + unsigned GNUSyntax : 1; /// The number of designators in this initializer expression. unsigned NumDesignators : 15; diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 54939024d0d..1f0536472b0 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -1758,12 +1758,12 @@ class CXXNewExpr : public Expr { SourceRange DirectInitRange; /// Was the usage ::new, i.e. is the global new to be used? - bool GlobalNew : 1; + unsigned GlobalNew : 1; /// Do we allocate an array? If so, the first SubExpr is the size expression. - bool Array : 1; + unsigned Array : 1; /// If this is an array allocation, does the usual deallocation /// function for the allocated type want to know the allocated size? - bool UsualArrayDeleteWantsSize : 1; + unsigned UsualArrayDeleteWantsSize : 1; /// The number of placement new arguments. unsigned NumPlacementArgs : 13; /// What kind of initializer do we have? Could be none, parens, or braces. @@ -2362,7 +2362,7 @@ class ExpressionTraitExpr : public Expr { /// \brief The trait. A ExpressionTrait enum in MSVC compatible unsigned. unsigned ET : 31; /// \brief The value of the type trait. Unspecified if dependent. - bool Value : 1; + unsigned Value : 1; /// \brief The location of the type trait keyword. SourceLocation Loc; diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index e344d6feae2..46bf06d8219 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -196,7 +196,7 @@ public: private: /// Certain options suppress the 'no input files' warning. - bool SuppressMissingInputWarning : 1; + unsigned SuppressMissingInputWarning : 1; std::list<std::string> TempFiles; std::list<std::string> ResultFiles; diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 1f04c996a14..c71419f2810 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -1155,10 +1155,10 @@ struct DeclaratorChunk { unsigned TypeQuals : 5; /// True if this dimension included the 'static' keyword. - bool hasStatic : 1; + unsigned hasStatic : 1; /// True if this dimension was [*]. In this case, NumElts is null. - bool isStar : 1; + unsigned isStar : 1; /// This is the size of the array, or null if [] or [*] was specified. /// Since the parser is multi-purpose, and we don't want to impose a root @@ -1663,10 +1663,10 @@ private: SmallVector<DeclaratorChunk, 8> DeclTypeInfo; /// InvalidType - Set by Sema::GetTypeForDeclarator(). - bool InvalidType : 1; + unsigned InvalidType : 1; /// GroupingParens - Set by Parser::ParseParenDeclarator(). - bool GroupingParens : 1; + unsigned GroupingParens : 1; /// FunctionDefinition - Is this Declarator for a function or member /// definition and, if so, what kind? @@ -1675,7 +1675,7 @@ private: unsigned FunctionDefinition : 2; /// \brief Is this Declarator a redeclaration? - bool Redeclaration : 1; + unsigned Redeclaration : 1; /// Attrs - Attributes. ParsedAttributes Attrs; diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h index abc1a07840c..d0c4db31200 100644 --- a/include/clang/Sema/Overload.h +++ b/include/clang/Sema/Overload.h @@ -397,7 +397,7 @@ namespace clang { /// \brief Whether the target is really a std::initializer_list, and the /// sequence only represents the worst element conversion. - bool StdInitializerListElement : 1; + unsigned StdInitializerListElement : 1; void setKind(Kind K) { destruct(); -- GitLab