Index: include/llvm/IR/DIBuilder.h =================================================================== --- include/llvm/IR/DIBuilder.h +++ include/llvm/IR/DIBuilder.h @@ -148,7 +148,7 @@ DIDerivedType *createMemberPointerType(DIType *PointeeTy, DIType *Class, uint64_t SizeInBits, uint64_t AlignInBits = 0, - unsigned Flags = 0); + DIFlagsUnderlying Flags = 0); /// Create debugging information entry for a c++ /// style reference or rvalue reference type. @@ -176,7 +176,7 @@ /// \param Flags Flags to describe inheritance attribute, /// e.g. private DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy, - uint64_t BaseOffset, unsigned Flags); + uint64_t BaseOffset, DIFlagsUnderlying Flags); /// Create debugging information entry for a member. /// \param Scope Member scope. @@ -191,7 +191,7 @@ DIDerivedType *createMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, DIType *Ty); /// Create debugging information entry for a bit field member. @@ -208,7 +208,7 @@ DIDerivedType *createBitFieldMemberType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - uint64_t StorageOffsetInBits, unsigned Flags, DIType *Ty); + uint64_t StorageOffsetInBits, DIFlagsUnderlying Flags, DIType *Ty); /// Create debugging information entry for a /// C++ static data member. @@ -221,7 +221,7 @@ /// \param Val Const initializer of the member. DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, - DIType *Ty, unsigned Flags, + DIType *Ty, DIFlagsUnderlying Flags, llvm::Constant *Val); /// Create debugging information entry for Objective-C @@ -237,7 +237,7 @@ /// \param PropertyNode Property associated with this ivar. DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, DIType *Ty, MDNode *PropertyNode); /// Create debugging information entry for Objective-C @@ -274,7 +274,7 @@ DICompositeType *createClassType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, DIType *DerivedFrom, DINodeArray Elements, DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr, @@ -293,7 +293,7 @@ /// \param UniqueIdentifier A unique identifier for the struct. DICompositeType *createStructType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, - uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, + uint64_t SizeInBits, uint64_t AlignInBits, DIFlagsUnderlying Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = ""); @@ -311,7 +311,7 @@ DICompositeType *createUnionType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, - unsigned Flags, DINodeArray Elements, + DIFlagsUnderlying Flags, DINodeArray Elements, unsigned RunTimeLang = 0, StringRef UniqueIdentifier = ""); @@ -393,7 +393,7 @@ /// These flags are used to emit dwarf attributes. /// \param CC Calling convention, e.g. dwarf::DW_CC_normal DISubroutineType *createSubroutineType(DITypeRefArray ParameterTypes, - unsigned Flags = 0, unsigned CC = 0); + DIFlagsUnderlying Flags = 0, unsigned CC = 0); /// Create an external type reference. /// \param Tag Dwarf TAG. @@ -421,7 +421,7 @@ DICompositeType *createReplaceableCompositeType( unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0, - uint64_t AlignInBits = 0, unsigned Flags = DINode::FlagFwdDecl, + uint64_t AlignInBits = 0, DIFlagsUnderlying Flags = DINode::FlagFwdDecl, StringRef UniqueIdentifier = ""); /// Retain DIScope* in a module even if it is not referenced @@ -480,7 +480,7 @@ DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false, - unsigned Flags = 0); + DIFlagsUnderlying Flags = 0); /// Create a new descriptor for a parameter variable. /// @@ -497,7 +497,7 @@ unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false, - unsigned Flags = 0); + DIFlagsUnderlying Flags = 0); /// Create a new descriptor for the specified /// variable which has a complex address expression for its address. @@ -532,7 +532,7 @@ StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, - unsigned ScopeLine, unsigned Flags = 0, + unsigned ScopeLine, DIFlagsUnderlying Flags = 0, bool isOptimized = false, DITemplateParameterArray TParams = nullptr, DISubprogram *Decl = nullptr); @@ -542,7 +542,7 @@ DISubprogram *createTempFunctionFwdDecl( DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, - bool isDefinition, unsigned ScopeLine, unsigned Flags = 0, + bool isDefinition, unsigned ScopeLine, DIFlagsUnderlying Flags = 0, bool isOptimized = false, DITemplateParameterArray TParams = nullptr, DISubprogram *Decl = nullptr); @@ -573,7 +573,7 @@ DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0, int ThisAdjustment = 0, - DIType *VTableHolder = nullptr, unsigned Flags = 0, + DIType *VTableHolder = nullptr, DIFlagsUnderlying Flags = 0, bool isOptimized = false, DITemplateParameterArray TParams = nullptr); Index: include/llvm/IR/DebugInfoMetadata.h =================================================================== --- include/llvm/IR/DebugInfoMetadata.h +++ include/llvm/IR/DebugInfoMetadata.h @@ -45,6 +45,9 @@ template class Optional; +/// Type capable of holding all DI flags values +typedef uint32_t DIFlagsUnderlying; + /// Holds a subclass of DINode. /// /// FIXME: This class doesn't currently make much sense. Previously it was a @@ -171,7 +174,7 @@ /// /// The three accessibility flags are mutually exclusive and rolled together /// in the first two bits. - enum DIFlags { + enum DIFlags : DIFlagsUnderlying { #define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID, #include "llvm/IR/DebugInfoFlags.def" FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic, @@ -179,15 +182,15 @@ FlagVirtualInheritance, }; - static unsigned getFlag(StringRef Flag); - static const char *getFlagString(unsigned Flag); + static DIFlagsUnderlying getFlag(StringRef Flag); + static const char *getFlagString(DIFlagsUnderlying Flag); /// \brief Split up a flags bitfield. /// /// Split \c Flags into \c SplitFlags, a vector of its components. Returns /// any remaining (unrecognized) bits. - static unsigned splitFlags(unsigned Flags, - SmallVectorImpl &SplitFlags); + static DIFlagsUnderlying splitFlags(DIFlagsUnderlying Flags, + SmallVectorImpl &SplitFlags); static bool classof(const Metadata *MD) { switch (MD->getMetadataID()) { @@ -508,7 +511,7 @@ /// TODO: Split up flags. class DIType : public DIScope { unsigned Line; - unsigned Flags; + DIFlagsUnderlying Flags; uint64_t SizeInBits; uint64_t AlignInBits; uint64_t OffsetInBits; @@ -516,14 +519,14 @@ protected: DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag, unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, ArrayRef Ops) + uint64_t OffsetInBits, DIFlagsUnderlying Flags, ArrayRef Ops) : DIScope(C, ID, Storage, Tag, Ops) { init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags); } ~DIType() = default; void init(unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags) { + uint64_t OffsetInBits, DIFlagsUnderlying Flags) { this->Line = Line; this->Flags = Flags; this->SizeInBits = SizeInBits; @@ -533,7 +536,7 @@ /// Change fields in place. void mutate(unsigned Tag, unsigned Line, uint64_t SizeInBits, - uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags) { + uint64_t AlignInBits, uint64_t OffsetInBits, DIFlagsUnderlying Flags) { assert(isDistinct() && "Only distinct nodes can mutate"); setTag(Tag); init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags); @@ -548,7 +551,7 @@ uint64_t getSizeInBits() const { return SizeInBits; } uint64_t getAlignInBits() const { return AlignInBits; } uint64_t getOffsetInBits() const { return OffsetInBits; } - unsigned getFlags() const { return Flags; } + DIFlagsUnderlying getFlags() const { return Flags; } DIScopeRef getScope() const { return DIScopeRef(getRawScope()); } StringRef getName() const { return getStringOperand(2); } @@ -557,7 +560,7 @@ Metadata *getRawScope() const { return getOperand(1); } MDString *getRawName() const { return getOperandAs(2); } - void setFlags(unsigned NewFlags) { + void setFlags(DIFlagsUnderlying NewFlags) { assert(!isUniqued() && "Cannot set flags on uniqued nodes"); Flags = NewFlags; } @@ -668,7 +671,7 @@ DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag, unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, ArrayRef Ops) + uint64_t OffsetInBits, DIFlagsUnderlying Flags, ArrayRef Ops) : DIType(C, DIDerivedTypeKind, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags, Ops) {} ~DIDerivedType() = default; @@ -677,7 +680,7 @@ StringRef Name, DIFile *File, unsigned Line, DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *ExtraData, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File, @@ -688,7 +691,7 @@ MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *ExtraData, StorageType Storage, bool ShouldCreate = true); @@ -704,7 +707,7 @@ (unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *ExtraData = nullptr), (Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, ExtraData)) @@ -712,7 +715,7 @@ (unsigned Tag, StringRef Name, DIFile *File, unsigned Line, DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, Metadata *ExtraData = nullptr), + DIFlagsUnderlying Flags, Metadata *ExtraData = nullptr), (Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, ExtraData)) @@ -772,7 +775,7 @@ DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, - uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, + uint64_t AlignInBits, uint64_t OffsetInBits, DIFlagsUnderlying Flags, ArrayRef Ops) : DIType(C, DICompositeTypeKind, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags, Ops), @@ -782,7 +785,7 @@ /// Change fields in place. void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags) { + DIFlagsUnderlying Flags) { assert(isDistinct() && "Only distinct nodes can mutate"); assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate"); this->RuntimeLang = RuntimeLang; @@ -793,7 +796,7 @@ getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File, unsigned Line, DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - uint64_t Flags, DINodeArray Elements, unsigned RuntimeLang, + DIFlagsUnderlying Flags, DINodeArray Elements, unsigned RuntimeLang, DITypeRef VTableHolder, DITemplateParameterArray TemplateParams, StringRef Identifier, StorageType Storage, bool ShouldCreate = true) { return getImpl( @@ -806,7 +809,7 @@ getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, Metadata *Elements, unsigned RuntimeLang, + DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, MDString *Identifier, StorageType Storage, bool ShouldCreate = true); @@ -823,7 +826,7 @@ (unsigned Tag, StringRef Name, DIFile *File, unsigned Line, DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, DINodeArray Elements, unsigned RuntimeLang, + DIFlagsUnderlying Flags, DINodeArray Elements, unsigned RuntimeLang, DITypeRef VTableHolder, DITemplateParameterArray TemplateParams = nullptr, StringRef Identifier = ""), @@ -834,7 +837,7 @@ (unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, Metadata *Elements, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams = nullptr, MDString *Identifier = nullptr), @@ -855,7 +858,7 @@ getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, Metadata *Elements, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams); static DICompositeType *getODRTypeIfExists(LLVMContext &Context, @@ -874,7 +877,7 @@ buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, Metadata *Elements, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams); @@ -933,20 +936,20 @@ /// type dwarf::CallingConvention. uint8_t CC; - DISubroutineType(LLVMContext &C, StorageType Storage, unsigned Flags, + DISubroutineType(LLVMContext &C, StorageType Storage, DIFlagsUnderlying Flags, uint8_t CC, ArrayRef Ops) : DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type, 0, 0, 0, 0, Flags, Ops), CC(CC) {} ~DISubroutineType() = default; - static DISubroutineType *getImpl(LLVMContext &Context, unsigned Flags, + static DISubroutineType *getImpl(LLVMContext &Context, DIFlagsUnderlying Flags, uint8_t CC, DITypeRefArray TypeArray, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate); } - static DISubroutineType *getImpl(LLVMContext &Context, unsigned Flags, + static DISubroutineType *getImpl(LLVMContext &Context, DIFlagsUnderlying Flags, uint8_t CC, Metadata *TypeArray, StorageType Storage, bool ShouldCreate = true); @@ -957,10 +960,10 @@ public: DEFINE_MDNODE_GET(DISubroutineType, - (unsigned Flags, uint8_t CC, DITypeRefArray TypeArray), + (DIFlagsUnderlying Flags, uint8_t CC, DITypeRefArray TypeArray), (Flags, CC, TypeArray)) DEFINE_MDNODE_GET(DISubroutineType, - (unsigned Flags, uint8_t CC, Metadata *TypeArray), + (DIFlagsUnderlying Flags, uint8_t CC, Metadata *TypeArray), (Flags, CC, TypeArray)) TempDISubroutineType clone() const { return cloneImpl(); } @@ -1299,7 +1302,7 @@ // in 2 bits (none/pure/pure_virtual). unsigned Virtuality : 2; - unsigned Flags : 27; + DIFlagsUnderlying Flags : 27; // These are boolean flags so one bit is enough. // MSVC starts a new container field every time the base @@ -1311,7 +1314,7 @@ DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line, unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex, - int ThisAdjustment, unsigned Flags, bool IsLocalToUnit, + int ThisAdjustment, DIFlagsUnderlying Flags, bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, ArrayRef Ops) : DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram, Ops), @@ -1330,7 +1333,7 @@ StringRef LinkageName, DIFile *File, unsigned Line, DISubroutineType *Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality, - unsigned VirtualIndex, int ThisAdjustment, unsigned Flags, + unsigned VirtualIndex, int ThisAdjustment, DIFlagsUnderlying Flags, bool IsOptimized, DICompileUnit *Unit, DITemplateParameterArray TemplateParams, DISubprogram *Declaration, DILocalVariableArray Variables, StorageType Storage, @@ -1347,7 +1350,7 @@ MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex, - int ThisAdjustment, unsigned Flags, bool IsOptimized, Metadata *Unit, + int ThisAdjustment, DIFlagsUnderlying Flags, bool IsOptimized, Metadata *Unit, Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables, StorageType Storage, bool ShouldCreate = true); @@ -1366,7 +1369,7 @@ DIFile *File, unsigned Line, DISubroutineType *Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality, - unsigned VirtualIndex, int ThisAdjustment, unsigned Flags, + unsigned VirtualIndex, int ThisAdjustment, DIFlagsUnderlying Flags, bool IsOptimized, DICompileUnit *Unit, DITemplateParameterArray TemplateParams = nullptr, DISubprogram *Declaration = nullptr, @@ -1380,7 +1383,7 @@ (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality, - unsigned VirtualIndex, int ThisAdjustment, unsigned Flags, + unsigned VirtualIndex, int ThisAdjustment, DIFlagsUnderlying Flags, bool IsOptimized, Metadata *Unit, Metadata *TemplateParams = nullptr, Metadata *Declaration = nullptr, Metadata *Variables = nullptr), (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, @@ -1395,12 +1398,12 @@ unsigned getVirtualIndex() const { return VirtualIndex; } int getThisAdjustment() const { return ThisAdjustment; } unsigned getScopeLine() const { return ScopeLine; } - unsigned getFlags() const { return Flags; } + DIFlagsUnderlying getFlags() const { return Flags; } bool isLocalToUnit() const { return IsLocalToUnit; } bool isDefinition() const { return IsDefinition; } bool isOptimized() const { return IsOptimized; } - unsigned isArtificial() const { return getFlags() & FlagArtificial; } + bool isArtificial() const { return getFlags() & FlagArtificial; } bool isPrivate() const { return (getFlags() & FlagAccessibility) == FlagPrivate; } @@ -1417,7 +1420,7 @@ /// /// Return true if this subprogram is a C++11 reference-qualified non-static /// member function (void foo() &). - unsigned isLValueReference() const { + bool isLValueReference() const { return getFlags() & FlagLValueReference; } @@ -1425,14 +1428,14 @@ /// /// Return true if this subprogram is a C++11 rvalue-reference-qualified /// non-static member function (void foo() &&). - unsigned isRValueReference() const { + bool isRValueReference() const { return getFlags() & FlagRValueReference; } /// \brief Check if this is marked as noreturn. /// /// Return true if this subprogram is C++11 noreturn or C11 _Noreturn - unsigned isNoReturn() const { + bool isNoReturn() const { return getFlags() & FlagNoReturn; } @@ -1955,20 +1958,19 @@ friend class MDNode; unsigned Arg : 16; - unsigned Flags : 16; + DIFlagsUnderlying Flags; DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line, - unsigned Arg, unsigned Flags, ArrayRef Ops) + unsigned Arg, DIFlagsUnderlying Flags, ArrayRef Ops) : DIVariable(C, DILocalVariableKind, Storage, Line, Ops), Arg(Arg), Flags(Flags) { - assert(Flags < (1 << 16) && "DILocalVariable: Flags out of range"); assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range"); } ~DILocalVariable() = default; static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name, DIFile *File, unsigned Line, - DITypeRef Type, unsigned Arg, unsigned Flags, + DITypeRef Type, unsigned Arg, DIFlagsUnderlying Flags, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File, @@ -1976,7 +1978,7 @@ } static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, - Metadata *Type, unsigned Arg, unsigned Flags, + Metadata *Type, unsigned Arg, DIFlagsUnderlying Flags, StorageType Storage, bool ShouldCreate = true); @@ -1989,12 +1991,12 @@ DEFINE_MDNODE_GET(DILocalVariable, (DILocalScope * Scope, StringRef Name, DIFile *File, unsigned Line, DITypeRef Type, unsigned Arg, - unsigned Flags), + DIFlagsUnderlying Flags), (Scope, Name, File, Line, Type, Arg, Flags)) DEFINE_MDNODE_GET(DILocalVariable, (Metadata * Scope, MDString *Name, Metadata *File, unsigned Line, Metadata *Type, unsigned Arg, - unsigned Flags), + DIFlagsUnderlying Flags), (Scope, Name, File, Line, Type, Arg, Flags)) TempDILocalVariable clone() const { return cloneImpl(); } @@ -2008,7 +2010,7 @@ bool isParameter() const { return Arg; } unsigned getArg() const { return Arg; } - unsigned getFlags() const { return Flags; } + DIFlagsUnderlying getFlags() const { return Flags; } bool isArtificial() const { return getFlags() & FlagArtificial; } bool isObjectPointer() const { return getFlags() & FlagObjectPointer; } Index: lib/IR/DIBuilder.cpp =================================================================== --- lib/IR/DIBuilder.cpp +++ lib/IR/DIBuilder.cpp @@ -221,7 +221,7 @@ DIType *Base, uint64_t SizeInBits, uint64_t AlignInBits, - unsigned Flags) { + DIFlagsUnderlying Flags) { return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "", nullptr, 0, nullptr, PointeeTy, SizeInBits, AlignInBits, 0, Flags, Base); @@ -252,7 +252,7 @@ DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy, uint64_t BaseOffset, - unsigned Flags) { + DIFlagsUnderlying Flags) { assert(Ty && "Unable to create inheritance"); return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr, 0, Ty, BaseTy, 0, 0, BaseOffset, Flags); @@ -263,7 +263,7 @@ uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, DIType *Ty) { + DIFlagsUnderlying Flags, DIType *Ty) { return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, getNonCompileUnitScope(Scope), Ty, SizeInBits, AlignInBits, OffsetInBits, Flags); @@ -278,7 +278,7 @@ DIDerivedType *DIBuilder::createBitFieldMemberType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - uint64_t StorageOffsetInBits, unsigned Flags, DIType *Ty) { + uint64_t StorageOffsetInBits, DIFlagsUnderlying Flags, DIType *Ty) { Flags |= DINode::FlagBitField; return DIDerivedType::get( VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, @@ -290,7 +290,7 @@ DIDerivedType *DIBuilder::createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, - DIType *Ty, unsigned Flags, + DIType *Ty, DIFlagsUnderlying Flags, llvm::Constant *Val) { Flags |= DINode::FlagStaticMember; return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File, @@ -302,7 +302,7 @@ unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, - uint64_t OffsetInBits, unsigned Flags, + uint64_t OffsetInBits, DIFlagsUnderlying Flags, DIType *Ty, MDNode *PropertyNode) { return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, getNonCompileUnitScope(File), Ty, @@ -360,7 +360,7 @@ DICompositeType *DIBuilder::createClassType( DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, DIType *DerivedFrom, DINodeArray Elements, + DIFlagsUnderlying Flags, DIType *DerivedFrom, DINodeArray Elements, DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) { assert((!Context || isa(Context)) && "createClassType should be called with a valid Context"); @@ -376,7 +376,7 @@ DICompositeType *DIBuilder::createStructType( DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber, - uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, + uint64_t SizeInBits, uint64_t AlignInBits, DIFlagsUnderlying Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang, DIType *VTableHolder, StringRef UniqueIdentifier) { auto *R = DICompositeType::get( @@ -389,7 +389,7 @@ DICompositeType *DIBuilder::createUnionType( DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, - uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, + uint64_t SizeInBits, uint64_t AlignInBits, DIFlagsUnderlying Flags, DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) { auto *R = DICompositeType::get( VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber, @@ -400,7 +400,7 @@ } DISubroutineType *DIBuilder::createSubroutineType(DITypeRefArray ParameterTypes, - unsigned Flags, unsigned CC) { + DIFlagsUnderlying Flags, unsigned CC) { return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes); } @@ -446,7 +446,7 @@ } static DIType *createTypeWithFlags(LLVMContext &Context, DIType *Ty, - unsigned FlagsToSet) { + DIFlagsUnderlying FlagsToSet) { auto NewTy = Ty->clone(); NewTy->setFlags(NewTy->getFlags() | FlagsToSet); return MDNode::replaceWithUniqued(std::move(NewTy)); @@ -463,7 +463,7 @@ // FIXME: Restrict this to the nodes where it's valid. if (Ty->isObjectPointer()) return Ty; - unsigned Flags = DINode::FlagObjectPointer | DINode::FlagArtificial; + DIFlagsUnderlying Flags = DINode::FlagObjectPointer | DINode::FlagArtificial; return createTypeWithFlags(VMContext, Ty, Flags); } @@ -495,7 +495,7 @@ DICompositeType *DIBuilder::createReplaceableCompositeType( unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits, - unsigned Flags, StringRef UniqueIdentifier) { + DIFlagsUnderlying Flags, StringRef UniqueIdentifier) { auto *RetTy = DICompositeType::getTemporary( VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr, @@ -565,7 +565,7 @@ LLVMContext &VMContext, DenseMap> &PreservedVariables, DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, - unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) { + unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DIFlagsUnderlying Flags) { // FIXME: Why getNonCompileUnitScope()? // FIXME: Why is "!Context" okay here? // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT @@ -589,7 +589,7 @@ DILocalVariable *DIBuilder::createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve, - unsigned Flags) { + DIFlagsUnderlying Flags) { return createLocalVariable(VMContext, PreservedVariables, Scope, Name, /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve, Flags); @@ -597,7 +597,7 @@ DILocalVariable *DIBuilder::createParameterVariable( DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, - unsigned LineNo, DIType *Ty, bool AlwaysPreserve, unsigned Flags) { + unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DIFlagsUnderlying Flags) { assert(ArgNo && "Expected non-zero argument number for parameter"); return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo, File, LineNo, Ty, AlwaysPreserve, Flags); @@ -629,7 +629,7 @@ DISubprogram *DIBuilder::createFunction( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, - bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized, + bool isDefinition, unsigned ScopeLine, DIFlagsUnderlying Flags, bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl) { auto *Node = getSubprogram( /* IsDistinct = */ isDefinition, VMContext, @@ -647,7 +647,7 @@ DISubprogram *DIBuilder::createTempFunctionFwdDecl( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, - bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized, + bool isDefinition, unsigned ScopeLine, DIFlagsUnderlying Flags, bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl) { return DISubprogram::getTemporary( VMContext, getNonCompileUnitScope(Context), Name, LinkageName, @@ -662,7 +662,7 @@ DIFile *F, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned VK, unsigned VIndex, int ThisAdjustment, - DIType *VTableHolder, unsigned Flags, bool isOptimized, + DIType *VTableHolder, DIFlagsUnderlying Flags, bool isOptimized, DITemplateParameterArray TParams) { assert(getNonCompileUnitScope(Context) && "Methods should have both a Context and a context that isn't " Index: lib/IR/DebugInfoMetadata.cpp =================================================================== --- lib/IR/DebugInfoMetadata.cpp +++ lib/IR/DebugInfoMetadata.cpp @@ -65,14 +65,14 @@ Storage, Context.pImpl->DILocations); } -unsigned DINode::getFlag(StringRef Flag) { - return StringSwitch(Flag) +DIFlagsUnderlying DINode::getFlag(StringRef Flag) { + return StringSwitch(Flag) #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME) #include "llvm/IR/DebugInfoFlags.def" .Default(0); } -const char *DINode::getFlagString(unsigned Flag) { +const char *DINode::getFlagString(DIFlagsUnderlying Flag) { switch (Flag) { default: return ""; @@ -83,11 +83,11 @@ } } -unsigned DINode::splitFlags(unsigned Flags, - SmallVectorImpl &SplitFlags) { +DIFlagsUnderlying DINode::splitFlags(DIFlagsUnderlying Flags, + SmallVectorImpl &SplitFlags) { // Accessibility and member pointer flags need to be specially handled, since // they're packed together. - if (unsigned A = Flags & FlagAccessibility) { + if (DIFlagsUnderlying A = Flags & FlagAccessibility) { if (A == FlagPrivate) SplitFlags.push_back(FlagPrivate); else if (A == FlagProtected) @@ -96,7 +96,7 @@ SplitFlags.push_back(FlagPublic); Flags &= ~A; } - if (unsigned R = Flags & FlagPtrToMemberRep) { + if (DIFlagsUnderlying R = Flags & FlagPtrToMemberRep) { if (R == FlagSingleInheritance) SplitFlags.push_back(FlagSingleInheritance); else if (R == FlagMultipleInheritance) @@ -107,7 +107,7 @@ } #define HANDLE_DI_FLAG(ID, NAME) \ - if (unsigned Bit = Flags & ID) { \ + if (DIFlagsUnderlying Bit = Flags & ID) { \ SplitFlags.push_back(Bit); \ Flags &= ~Bit; \ } @@ -242,7 +242,7 @@ DIDerivedType *DIDerivedType::getImpl( LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, - uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, + uint64_t AlignInBits, uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *ExtraData, StorageType Storage, bool ShouldCreate) { assert(isCanonical(Name) && "Expected canonical MDString"); DEFINE_GETIMPL_LOOKUP(DIDerivedType, @@ -257,7 +257,7 @@ DICompositeType *DICompositeType::getImpl( LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, - uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, + uint64_t AlignInBits, uint64_t OffsetInBits, DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, MDString *Identifier, StorageType Storage, bool ShouldCreate) { @@ -279,7 +279,7 @@ LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, Metadata *Elements, unsigned RuntimeLang, + DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams) { assert(!Identifier.getString().empty() && "Expected valid identifier"); if (!Context.isODRUniquingDebugTypes()) @@ -313,7 +313,7 @@ LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, - unsigned Flags, Metadata *Elements, unsigned RuntimeLang, + DIFlagsUnderlying Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams) { assert(!Identifier.getString().empty() && "Expected valid identifier"); if (!Context.isODRUniquingDebugTypes()) @@ -336,7 +336,7 @@ } DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, - unsigned Flags, uint8_t CC, + DIFlagsUnderlying Flags, uint8_t CC, Metadata *TypeArray, StorageType Storage, bool ShouldCreate) { @@ -414,7 +414,7 @@ MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex, - int ThisAdjustment, unsigned Flags, bool IsOptimized, Metadata *Unit, + int ThisAdjustment, DIFlagsUnderlying Flags, bool IsOptimized, Metadata *Unit, Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables, StorageType Storage, bool ShouldCreate) { assert(isCanonical(Name) && "Expected canonical MDString"); @@ -529,7 +529,7 @@ DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, Metadata *Type, - unsigned Arg, unsigned Flags, + unsigned Arg, DIFlagsUnderlying Flags, StorageType Storage, bool ShouldCreate) { // 64K ought to be enough for any frontend.