diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 7a4152994b98..c04f07c534af 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -256,11 +256,13 @@ class GenericDINode : public DINode { public: unsigned getHash() const { return SubclassData32; } - DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, StringRef Header, - ArrayRef DwarfOps), + DEFINE_MDNODE_GET(GenericDINode, + (unsigned Tag, StringRef Header, + ArrayRef DwarfOps), (Tag, Header, DwarfOps)) - DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, MDString *Header, - ArrayRef DwarfOps), + DEFINE_MDNODE_GET(GenericDINode, + (unsigned Tag, MDString *Header, + ArrayRef DwarfOps), (Tag, Header, DwarfOps)) /// Return a (temporary) clone of this. @@ -324,7 +326,7 @@ public: DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0), (Count, LowerBound)) - DEFINE_MDNODE_GET(DISubrange, (Metadata *CountNode, int64_t LowerBound = 0), + DEFINE_MDNODE_GET(DISubrange, (Metadata * CountNode, int64_t LowerBound = 0), (CountNode, LowerBound)) DEFINE_MDNODE_GET(DISubrange, @@ -334,9 +336,7 @@ public: TempDISubrange clone() const { return cloneImpl(); } - Metadata *getRawCountNode() const { - return getOperand(0).get(); - } + Metadata *getRawCountNode() const { return getOperand(0).get(); } Metadata *getRawLowerBound() const { return getOperand(1).get(); } @@ -548,14 +548,13 @@ public: }; /// A single checksum, represented by a \a Kind and a \a Value (a string). - template - struct ChecksumInfo { + template struct ChecksumInfo { /// The kind of checksum which \a Value encodes. ChecksumKind Kind; /// The string value of the checksum. T Value; - ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { } + ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) {} ~ChecksumInfo() = default; bool operator==(const ChecksumInfo &X) const { return Kind == X.Kind && Value == X.Value; @@ -578,15 +577,17 @@ private: static DIFile *getImpl(LLVMContext &Context, StringRef Filename, StringRef Directory, Optional> CS, - Optional Source, - StorageType Storage, bool ShouldCreate = true) { + Optional Source, StorageType Storage, + bool ShouldCreate = true) { Optional> MDChecksum; if (CS) MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value)); - return getImpl(Context, getCanonicalMDString(Context, Filename), - getCanonicalMDString(Context, Directory), MDChecksum, - Source ? Optional(getCanonicalMDString(Context, *Source)) : None, - Storage, ShouldCreate); + return getImpl( + Context, getCanonicalMDString(Context, Filename), + getCanonicalMDString(Context, Directory), MDChecksum, + Source ? Optional(getCanonicalMDString(Context, *Source)) + : None, + Storage, ShouldCreate); } static DIFile *getImpl(LLVMContext &Context, MDString *Filename, MDString *Directory, @@ -600,13 +601,15 @@ private: } public: - DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory, - Optional> CS = None, - Optional Source = None), + DEFINE_MDNODE_GET(DIFile, + (StringRef Filename, StringRef Directory, + Optional> CS = None, + Optional Source = None), (Filename, Directory, CS, Source)) - DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory, - Optional> CS = None, - Optional Source = None), + DEFINE_MDNODE_GET(DIFile, + (MDString * Filename, MDString *Directory, + Optional> CS = None, + Optional Source = None), (Filename, Directory, CS, Source)) TempDIFile clone() const { return cloneImpl(); } @@ -707,7 +710,6 @@ public: DIScope *getScope() const { return cast_or_null(getRawScope()); } StringRef getName() const { return getStringOperand(2); } - Metadata *getRawScope() const { return getOperand(1); } MDString *getRawName() const { return getOperandAs(2); } @@ -959,17 +961,15 @@ class DIDerivedType : public DIType { } public: - DEFINE_MDNODE_GET(DIDerivedType, - (unsigned Tag, MDString *Name, Metadata *File, - unsigned Line, Metadata *Scope, Metadata *BaseType, - uint64_t SizeInBits, uint32_t AlignInBits, - uint64_t OffsetInBits, - Optional DWARFAddressSpace, DIFlags Flags, - Metadata *ExtraData = nullptr, - Metadata *Annotations = nullptr), - (Tag, Name, File, Line, Scope, BaseType, SizeInBits, - AlignInBits, OffsetInBits, DWARFAddressSpace, Flags, - ExtraData, Annotations)) + DEFINE_MDNODE_GET( + DIDerivedType, + (unsigned Tag, MDString *Name, Metadata *File, unsigned Line, + Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, + uint32_t AlignInBits, uint64_t OffsetInBits, + Optional DWARFAddressSpace, DIFlags Flags, + Metadata *ExtraData = nullptr, Metadata *Annotations = nullptr), + (Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits, + OffsetInBits, DWARFAddressSpace, Flags, ExtraData, Annotations)) DEFINE_MDNODE_GET(DIDerivedType, (unsigned Tag, StringRef Name, DIFile *File, unsigned Line, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits, @@ -1074,8 +1074,8 @@ class DICompositeType : public DIType { /// Change fields in place. void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang, - uint64_t SizeInBits, uint32_t AlignInBits, - uint64_t OffsetInBits, DIFlags Flags) { + uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, + DIFlags Flags) { assert(isDistinct() && "Only distinct nodes can mutate"); assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate"); this->RuntimeLang = RuntimeLang; @@ -1209,7 +1209,9 @@ public: Metadata *getRawTemplateParams() const { return getOperand(6); } MDString *getRawIdentifier() const { return getOperandAs(7); } Metadata *getRawDiscriminator() const { return getOperand(8); } - DIDerivedType *getDiscriminator() const { return getOperandAs(8); } + DIDerivedType *getDiscriminator() const { + return getOperandAs(8); + } Metadata *getRawDataLocation() const { return getOperand(9); } DIVariable *getDataLocation() const { return dyn_cast_or_null(getRawDataLocation()); @@ -1525,9 +1527,7 @@ public: void replaceEnumTypes(DICompositeTypeArray N) { replaceOperandWith(4, N.get()); } - void replaceRetainedTypes(DITypeArray N) { - replaceOperandWith(5, N.get()); - } + void replaceRetainedTypes(DITypeArray N) { replaceOperandWith(5, N.get()); } void replaceGlobalVariables(DIGlobalVariableExpressionArray N) { replaceOperandWith(6, N.get()); } @@ -1709,7 +1709,8 @@ public: /// base discriminator is set in the new DILocation, the other encoded values /// are elided. /// If the discriminator cannot be encoded, the function returns None. - inline Optional cloneWithBaseDiscriminator(unsigned BD) const; + inline Optional + cloneWithBaseDiscriminator(unsigned BD) const; /// Returns the duplication factor stored in the discriminator, or 1 if no /// duplication factor (or 0) is encoded. @@ -1725,7 +1726,8 @@ public: /// duplication factor encoded in the discriminator. The current duplication /// factor is as defined by getDuplicationFactor(). /// Returns None if encoding failed. - inline Optional cloneByMultiplyingDuplicationFactor(unsigned DF) const; + inline Optional + cloneByMultiplyingDuplicationFactor(unsigned DF) const; /// When two instructions are combined into a single instruction we also /// need to combine the original locations into a single location. @@ -1748,8 +1750,8 @@ public: /// This function applies getMergedLocation() repeatedly left-to-right. /// /// \p Locs: The locations to be merged. - static - const DILocation *getMergedLocations(ArrayRef Locs); + static const DILocation * + getMergedLocations(ArrayRef Locs); /// Return the masked discriminator value for an input discrimnator value D /// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base). @@ -1773,13 +1775,18 @@ public: /// Raw encoding of the discriminator. APIs such as cloneWithDuplicationFactor /// have certain special case behavior (e.g. treating empty duplication factor /// as the value '1'). - /// This API, in conjunction with cloneWithDiscriminator, may be used to encode - /// the raw values provided. \p BD: base discriminator \p DF: duplication factor + /// This API, in conjunction with cloneWithDiscriminator, may be used to + /// encode the raw values provided. + /// + /// \p BD: base discriminator + /// \p DF: duplication factor /// \p CI: copy index + /// /// The return is None if the values cannot be encoded in 32 bits - for - /// example, values for BD or DF larger than 12 bits. Otherwise, the return - /// is the encoded value. - static Optional encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI); + /// example, values for BD or DF larger than 12 bits. Otherwise, the return is + /// the encoded value. + static Optional encodeDiscriminator(unsigned BD, unsigned DF, + unsigned CI); /// Raw decoder for values in an encoded discriminator D. static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, @@ -1799,11 +1806,10 @@ public: /// Returns the copy identifier for a given encoded discriminator \p D. static unsigned getCopyIdentifierFromDiscriminator(unsigned D) { - return getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator( - getNextComponentInDiscriminator(D))); + return getUnsignedFromPrefixEncoding( + getNextComponentInDiscriminator(getNextComponentInDiscriminator(D))); } - Metadata *getRawScope() const { return getOperand(0); } Metadata *getRawInlinedAt() const { if (getNumOperands() == 2) @@ -1857,10 +1863,10 @@ public: unsigned Virtuality = SPFlagNonvirtual, bool IsMainSubprogram = false) { // We're assuming virtuality is the low-order field. - static_assert( - int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) && - int(SPFlagPureVirtual) == int(dwarf::DW_VIRTUALITY_pure_virtual), - "Virtuality constant mismatch"); + static_assert(int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) && + int(SPFlagPureVirtual) == + int(dwarf::DW_VIRTUALITY_pure_virtual), + "Virtuality constant mismatch"); return static_cast( (Virtuality & SPFlagVirtuality) | (IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) | @@ -1901,16 +1907,14 @@ private: RetainedNodes.get(), ThrownTypes.get(), Annotations.get(), Storage, ShouldCreate); } - static DISubprogram *getImpl(LLVMContext &Context, Metadata *Scope, - MDString *Name, MDString *LinkageName, - Metadata *File, unsigned Line, Metadata *Type, - unsigned ScopeLine, Metadata *ContainingType, - unsigned VirtualIndex, int ThisAdjustment, - DIFlags Flags, DISPFlags SPFlags, Metadata *Unit, - Metadata *TemplateParams, Metadata *Declaration, - Metadata *RetainedNodes, Metadata *ThrownTypes, - Metadata *Annotations, StorageType Storage, - bool ShouldCreate = true); + static DISubprogram * + getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, + MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type, + unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex, + int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit, + Metadata *TemplateParams, Metadata *Declaration, + Metadata *RetainedNodes, Metadata *ThrownTypes, Metadata *Annotations, + StorageType Storage, bool ShouldCreate = true); TempDISubprogram cloneImpl() const { return getTemporary(getContext(), getScope(), getName(), getLinkageName(), @@ -1963,7 +1967,10 @@ public: unsigned getVirtualIndex() const { return VirtualIndex; } int getThisAdjustment() const { return ThisAdjustment; } unsigned getScopeLine() const { return ScopeLine; } - void setScopeLine(unsigned L) { assert(isDistinct()); ScopeLine = L; } + void setScopeLine(unsigned L) { + assert(isDistinct()); + ScopeLine = L; + } DIFlags getFlags() const { return Flags; } DISPFlags getSPFlags() const { return SPFlags; } bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; } @@ -2139,11 +2146,13 @@ class DILexicalBlock : public DILexicalBlockBase { } public: - DEFINE_MDNODE_GET(DILexicalBlock, (DILocalScope * Scope, DIFile *File, - unsigned Line, unsigned Column), + DEFINE_MDNODE_GET(DILexicalBlock, + (DILocalScope * Scope, DIFile *File, unsigned Line, + unsigned Column), (Scope, File, Line, Column)) - DEFINE_MDNODE_GET(DILexicalBlock, (Metadata * Scope, Metadata *File, - unsigned Line, unsigned Column), + DEFINE_MDNODE_GET(DILexicalBlock, + (Metadata * Scope, Metadata *File, unsigned Line, + unsigned Column), (Scope, File, Line, Column)) TempDILexicalBlock clone() const { return cloneImpl(); } @@ -2188,8 +2197,9 @@ class DILexicalBlockFile : public DILexicalBlockBase { } public: - DEFINE_MDNODE_GET(DILexicalBlockFile, (DILocalScope * Scope, DIFile *File, - unsigned Discriminator), + DEFINE_MDNODE_GET(DILexicalBlockFile, + (DILocalScope * Scope, DIFile *File, + unsigned Discriminator), (Scope, File, Discriminator)) DEFINE_MDNODE_GET(DILexicalBlockFile, (Metadata * Scope, Metadata *File, unsigned Discriminator), @@ -2303,10 +2313,10 @@ class DINamespace : public DIScope { public: DEFINE_MDNODE_GET(DINamespace, - (DIScope *Scope, StringRef Name, bool ExportSymbols), + (DIScope * Scope, StringRef Name, bool ExportSymbols), (Scope, Name, ExportSymbols)) DEFINE_MDNODE_GET(DINamespace, - (Metadata *Scope, MDString *Name, bool ExportSymbols), + (Metadata * Scope, MDString *Name, bool ExportSymbols), (Scope, Name, ExportSymbols)) TempDINamespace clone() const { return cloneImpl(); } @@ -2455,7 +2465,7 @@ public: (StringRef Name, DIType *Type, bool IsDefault), (Name, Type, IsDefault)) DEFINE_MDNODE_GET(DITemplateTypeParameter, - (MDString *Name, Metadata *Type, bool IsDefault), + (MDString * Name, Metadata *Type, bool IsDefault), (Name, Type, IsDefault)) TempDITemplateTypeParameter clone() const { return cloneImpl(); } @@ -2848,7 +2858,8 @@ public: /// \param OffsetInBits Offset of the piece in bits. /// \param SizeInBits Size of the piece in bits. /// \return Creating a fragment expression may fail if \c Expr - /// contains arithmetic operations that would be truncated. + /// contains arithmetic operations that would be + /// truncated. static Optional createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits); @@ -2987,26 +2998,22 @@ class DIGlobalVariable : public DIVariable { } public: - DEFINE_MDNODE_GET(DIGlobalVariable, - (DIScope * Scope, StringRef Name, StringRef LinkageName, - DIFile *File, unsigned Line, DIType *Type, - bool IsLocalToUnit, bool IsDefinition, - DIDerivedType *StaticDataMemberDeclaration, - MDTuple *TemplateParams, uint32_t AlignInBits, - DINodeArray Annotations), - (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, - IsDefinition, StaticDataMemberDeclaration, TemplateParams, - AlignInBits, Annotations)) - DEFINE_MDNODE_GET(DIGlobalVariable, - (Metadata * Scope, MDString *Name, MDString *LinkageName, - Metadata *File, unsigned Line, Metadata *Type, - bool IsLocalToUnit, bool IsDefinition, - Metadata *StaticDataMemberDeclaration, - Metadata *TemplateParams, uint32_t AlignInBits, - Metadata *Annotations), - (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, - IsDefinition, StaticDataMemberDeclaration, TemplateParams, - AlignInBits, Annotations)) + DEFINE_MDNODE_GET( + DIGlobalVariable, + (DIScope * Scope, StringRef Name, StringRef LinkageName, DIFile *File, + unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition, + DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams, + uint32_t AlignInBits, DINodeArray Annotations), + (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, + StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations)) + DEFINE_MDNODE_GET( + DIGlobalVariable, + (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File, + unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition, + Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams, + uint32_t AlignInBits, Metadata *Annotations), + (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, + StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations)) TempDIGlobalVariable clone() const { return cloneImpl(); } @@ -3041,20 +3048,20 @@ class DICommonBlock : public DIScope { DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo, ArrayRef Ops) : DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block, - Ops), LineNo(LineNo) {} + Ops), + LineNo(LineNo) {} static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope, DIGlobalVariable *Decl, StringRef Name, DIFile *File, unsigned LineNo, - StorageType Storage, - bool ShouldCreate = true) { + StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name), File, LineNo, Storage, ShouldCreate); } static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope, Metadata *Decl, MDString *Name, Metadata *File, - unsigned LineNo, - StorageType Storage, bool ShouldCreate = true); + unsigned LineNo, StorageType Storage, + bool ShouldCreate = true); TempDICommonBlock cloneImpl() const { return getTemporary(getContext(), getScope(), getDecl(), getName(), @@ -3063,11 +3070,11 @@ class DICommonBlock : public DIScope { public: DEFINE_MDNODE_GET(DICommonBlock, - (DIScope *Scope, DIGlobalVariable *Decl, StringRef Name, + (DIScope * Scope, DIGlobalVariable *Decl, StringRef Name, DIFile *File, unsigned LineNo), (Scope, Decl, Name, File, LineNo)) DEFINE_MDNODE_GET(DICommonBlock, - (Metadata *Scope, Metadata *Decl, MDString *Name, + (Metadata * Scope, Metadata *Decl, MDString *Name, Metadata *File, unsigned LineNo), (Scope, Decl, Name, File, LineNo)) @@ -3114,16 +3121,18 @@ class DILocalVariable : public DIVariable { StringRef Name, DIFile *File, unsigned Line, DIType *Type, unsigned Arg, DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations, - StorageType Storage, bool ShouldCreate = true) { + StorageType Storage, + bool ShouldCreate = true) { return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File, - Line, Type, Arg, Flags, AlignInBits, Annotations.get(), Storage, - ShouldCreate); + Line, Type, Arg, Flags, AlignInBits, Annotations.get(), + Storage, ShouldCreate); } static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, Metadata *File, unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations, - StorageType Storage, bool ShouldCreate = true); + StorageType Storage, + bool ShouldCreate = true); TempDILocalVariable cloneImpl() const { return getTemporary(getContext(), getScope(), getName(), getFile(), @@ -3140,8 +3149,8 @@ public: Annotations)) DEFINE_MDNODE_GET(DILocalVariable, (Metadata * Scope, MDString *Name, Metadata *File, - unsigned Line, Metadata *Type, unsigned Arg, - DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations), + unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags, + uint32_t AlignInBits, Metadata *Annotations), (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits, Annotations)) @@ -3193,16 +3202,14 @@ class DILabel : public DINode { : DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops), Line(Line) {} ~DILabel() = default; - static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, - StringRef Name, DIFile *File, unsigned Line, - StorageType Storage, + static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name, + DIFile *File, unsigned Line, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File, Line, Storage, ShouldCreate); } - static DILabel *getImpl(LLVMContext &Context, Metadata *Scope, - MDString *Name, Metadata *File, unsigned Line, - StorageType Storage, + static DILabel *getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, + Metadata *File, unsigned Line, StorageType Storage, bool ShouldCreate = true); TempDILabel cloneImpl() const { @@ -3515,11 +3522,13 @@ class DIMacro : public DIMacroNode { } public: - DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, StringRef Name, - StringRef Value = ""), + DEFINE_MDNODE_GET(DIMacro, + (unsigned MIType, unsigned Line, StringRef Name, + StringRef Value = ""), (MIType, Line, Name, Value)) - DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, MDString *Name, - MDString *Value), + DEFINE_MDNODE_GET(DIMacro, + (unsigned MIType, unsigned Line, MDString *Name, + MDString *Value), (MIType, Line, Name, Value)) TempDIMacro clone() const { return cloneImpl(); } @@ -3566,11 +3575,13 @@ class DIMacroFile : public DIMacroNode { } public: - DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, DIFile *File, - DIMacroNodeArray Elements), + DEFINE_MDNODE_GET(DIMacroFile, + (unsigned MIType, unsigned Line, DIFile *File, + DIMacroNodeArray Elements), (MIType, Line, File, Elements)) - DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, - Metadata *File, Metadata *Elements), + DEFINE_MDNODE_GET(DIMacroFile, + (unsigned MIType, unsigned Line, Metadata *File, + Metadata *Elements), (MIType, Line, File, Elements)) TempDIMacroFile clone() const { return cloneImpl(); } diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 15e2386b508d..039a3b270919 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -362,7 +362,8 @@ class PlaceholderQueue { public: ~PlaceholderQueue() { - assert(empty() && "PlaceholderQueue hasn't been flushed before being destroyed"); + assert(empty() && + "PlaceholderQueue hasn't been flushed before being destroyed"); } bool empty() const { return PHs.empty(); } DistinctMDOperandPlaceholder &getPlaceholderOp(unsigned ID); @@ -603,7 +604,7 @@ class MetadataLoader::MetadataLoaderImpl { // If the expression is malformed, make sure we don't // copy more elements than we should. HistoricSize = std::min(SubExpr.size(), HistoricSize); - ArrayRef Args = SubExpr.slice(1, HistoricSize-1); + ArrayRef Args = SubExpr.slice(1, HistoricSize - 1); switch (SubExpr.front()) { case dwarf::DW_OP_plus: @@ -1408,8 +1409,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( return error("Invalid record"); IsDistinct = Record[0]; - DINode::DIFlags Flags = (Record.size() > 6) ? - static_cast(Record[6]) : DINode::FlagZero; + DINode::DIFlags Flags = (Record.size() > 6) + ? static_cast(Record[6]) + : DINode::FlagZero; MetadataList.assignValue( GET_OR_DISTINCT(DIBasicType, @@ -1670,9 +1672,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( SPFlags |= DISubprogram::SPFlagMainSubprogram; else if (!HasSPFlags) SPFlags = DISubprogram::toSPFlags( - /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8], - /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11], - /*DIFlagMainSubprogram*/HasOldMainSubprogramFlag); + /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8], + /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11], + /*DIFlagMainSubprogram=*/HasOldMainSubprogramFlag); // All definitions should be distinct. IsDistinct = (Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition); @@ -1709,26 +1711,26 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( DISubprogram *SP = GET_OR_DISTINCT( DISubprogram, (Context, - getDITypeRefOrNull(Record[1]), // scope - getMDString(Record[2]), // name - getMDString(Record[3]), // linkageName - getMDOrNull(Record[4]), // file - Record[5], // line - getMDOrNull(Record[6]), // type - Record[7 + OffsetA], // scopeLine - getDITypeRefOrNull(Record[8 + OffsetA]), // containingType - Record[10 + OffsetA], // virtualIndex - HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment - Flags, // flags - SPFlags, // SPFlags - HasUnit ? CUorFn : nullptr, // unit - getMDOrNull(Record[13 + OffsetB]), // templateParams - getMDOrNull(Record[14 + OffsetB]), // declaration - getMDOrNull(Record[15 + OffsetB]), // retainedNodes + getDITypeRefOrNull(Record[1]), // scope + getMDString(Record[2]), // name + getMDString(Record[3]), // linkageName + getMDOrNull(Record[4]), // file + Record[5], // line + getMDOrNull(Record[6]), // type + Record[7 + OffsetA], // scopeLine + getDITypeRefOrNull(Record[8 + OffsetA]), // containingType + Record[10 + OffsetA], // virtualIndex + HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment + Flags, // flags + SPFlags, // SPFlags + HasUnit ? CUorFn : nullptr, // unit + getMDOrNull(Record[13 + OffsetB]), // templateParams + getMDOrNull(Record[14 + OffsetB]), // declaration + getMDOrNull(Record[15 + OffsetB]), // retainedNodes HasThrownTypes ? getMDOrNull(Record[17 + OffsetB]) - : nullptr, // thrownTypes + : nullptr, // thrownTypes HasAnnotations ? getMDOrNull(Record[18 + OffsetB]) - : nullptr // annotations + : nullptr // annotations )); MetadataList.assignValue(SP, NextMetadataNo); NextMetadataNo++; @@ -1875,13 +1877,13 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( Annotations = getMDOrNull(Record[12]); MetadataList.assignValue( - GET_OR_DISTINCT( - DIGlobalVariable, - (Context, getMDOrNull(Record[1]), getMDString(Record[2]), - getMDString(Record[3]), getMDOrNull(Record[4]), Record[5], - getDITypeRefOrNull(Record[6]), Record[7], Record[8], - getMDOrNull(Record[9]), getMDOrNull(Record[10]), Record[11], - Annotations)), + GET_OR_DISTINCT(DIGlobalVariable, + (Context, getMDOrNull(Record[1]), + getMDString(Record[2]), getMDString(Record[3]), + getMDOrNull(Record[4]), Record[5], + getDITypeRefOrNull(Record[6]), Record[7], Record[8], + getMDOrNull(Record[9]), getMDOrNull(Record[10]), + Record[11], Annotations)), NextMetadataNo); NextMetadataNo++; @@ -1889,13 +1891,12 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( // No upgrade necessary. A null field will be introduced to indicate // that no parameter information is available. MetadataList.assignValue( - GET_OR_DISTINCT(DIGlobalVariable, - (Context, getMDOrNull(Record[1]), - getMDString(Record[2]), getMDString(Record[3]), - getMDOrNull(Record[4]), Record[5], - getDITypeRefOrNull(Record[6]), Record[7], Record[8], - getMDOrNull(Record[10]), nullptr, Record[11], - nullptr)), + GET_OR_DISTINCT( + DIGlobalVariable, + (Context, getMDOrNull(Record[1]), getMDString(Record[2]), + getMDString(Record[3]), getMDOrNull(Record[4]), Record[5], + getDITypeRefOrNull(Record[6]), Record[7], Record[8], + getMDOrNull(Record[10]), nullptr, Record[11], nullptr)), NextMetadataNo); NextMetadataNo++; @@ -1973,8 +1974,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( getMDString(Record[2 + HasTag]), getMDOrNull(Record[3 + HasTag]), Record[4 + HasTag], getDITypeRefOrNull(Record[5 + HasTag]), - Record[6 + HasTag], Flags, AlignInBits, - Annotations)), + Record[6 + HasTag], Flags, AlignInBits, Annotations)), NextMetadataNo); NextMetadataNo++; break; @@ -1985,10 +1985,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( IsDistinct = Record[0] & 1; MetadataList.assignValue( - GET_OR_DISTINCT(DILabel, - (Context, getMDOrNull(Record[1]), - getMDString(Record[2]), - getMDOrNull(Record[3]), Record[4])), + GET_OR_DISTINCT(DILabel, (Context, getMDOrNull(Record[1]), + getMDString(Record[2]), + getMDOrNull(Record[3]), Record[4])), NextMetadataNo); NextMetadataNo++; break; @@ -2005,8 +2004,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( if (Error Err = upgradeDIExpression(Version, Elts, Buffer)) return Err; - MetadataList.assignValue( - GET_OR_DISTINCT(DIExpression, (Context, Elts)), NextMetadataNo); + MetadataList.assignValue(GET_OR_DISTINCT(DIExpression, (Context, Elts)), + NextMetadataNo); NextMetadataNo++; break; } diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 12320cf4af9f..ca7dafc814ce 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -32,8 +32,8 @@ static cl::opt cl::init(false), cl::Hidden); DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU) - : M(m), VMContext(M.getContext()), CUNode(CU), - DeclareFn(nullptr), ValueFn(nullptr), LabelFn(nullptr), + : M(m), VMContext(M.getContext()), CUNode(CU), DeclareFn(nullptr), + ValueFn(nullptr), LabelFn(nullptr), AllowUnresolvedNodes(AllowUnresolvedNodes) {} void DIBuilder::trackIfUnresolved(MDNode *N) { @@ -309,11 +309,10 @@ DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy, AlignInBits, 0, None, Flags, Base); } -DIDerivedType *DIBuilder::createReferenceType( - unsigned Tag, DIType *RTy, - uint64_t SizeInBits, - uint32_t AlignInBits, - Optional DWARFAddressSpace) { +DIDerivedType * +DIBuilder::createReferenceType(unsigned Tag, DIType *RTy, uint64_t SizeInBits, + uint32_t AlignInBits, + Optional DWARFAddressSpace) { assert(RTy && "Unable to create reference type"); return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy, SizeInBits, AlignInBits, 0, DWARFAddressSpace, @@ -322,8 +321,7 @@ DIDerivedType *DIBuilder::createReferenceType( DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, - DIScope *Context, - uint32_t AlignInBits, + DIScope *Context, uint32_t AlignInBits, DINodeArray Annotations) { return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, LineNo, getNonCompileUnitScope(Context), Ty, 0, @@ -346,8 +344,8 @@ DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy, Metadata *ExtraData = ConstantAsMetadata::get( ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset)); return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr, - 0, Ty, BaseTy, 0, 0, BaseOffset, None, - Flags, ExtraData); + 0, Ty, BaseTy, 0, 0, BaseOffset, None, Flags, + ExtraData); } DIDerivedType *DIBuilder::createMemberType( @@ -383,7 +381,7 @@ DIDerivedType *DIBuilder::createBitFieldMemberType( Flags |= DINode::FlagBitField; return DIDerivedType::get( VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, - getNonCompileUnitScope(Scope), Ty, SizeInBits, /* AlignInBits */ 0, + getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0, OffsetInBits, None, Flags, ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64), StorageOffsetInBits)), @@ -503,10 +501,12 @@ DICompositeType *DIBuilder::createUnionType( return R; } -DICompositeType *DIBuilder::createVariantPart( - DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, - uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, - DIDerivedType *Discriminator, DINodeArray Elements, StringRef UniqueIdentifier) { +DICompositeType * +DIBuilder::createVariantPart(DIScope *Scope, StringRef Name, DIFile *File, + unsigned LineNumber, uint64_t SizeInBits, + uint32_t AlignInBits, DINode::DIFlags Flags, + DIDerivedType *Discriminator, DINodeArray Elements, + StringRef UniqueIdentifier) { auto *R = DICompositeType::get( VMContext, dwarf::DW_TAG_variant_part, Name, File, LineNumber, getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags, @@ -547,16 +547,17 @@ DIDerivedType *DIBuilder::createSetType(DIScope *Scope, StringRef Name, return R; } -DICompositeType *DIBuilder::createArrayType( - uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, - PointerUnion DL, - PointerUnion AS, - PointerUnion AL, - PointerUnion RK) { +DICompositeType * +DIBuilder::createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, + DINodeArray Subscripts, + PointerUnion DL, + PointerUnion AS, + PointerUnion AL, + PointerUnion RK) { auto *R = DICompositeType::get( - VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, - nullptr, Ty, Size, AlignInBits, 0, DINode::FlagZero, - Subscripts, 0, nullptr, nullptr, "", nullptr, + VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty, Size, + AlignInBits, 0, DINode::FlagZero, Subscripts, 0, nullptr, nullptr, "", + nullptr, DL.is() ? (Metadata *)DL.get() : (Metadata *)DL.get(), AS.is() ? (Metadata *)AS.get() @@ -639,8 +640,8 @@ DICompositeType *DIBuilder::createReplaceableCompositeType( DICompositeType::getTemporary( VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr, - nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr, nullptr, - Annotations) + nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr, + nullptr, Annotations) .release(); trackIfUnresolved(RetTy); return RetTy; @@ -708,16 +709,16 @@ static void checkGlobalVariableScope(DIScope *Context) { DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F, - unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, - bool isDefined, DIExpression *Expr, - MDNode *Decl, MDTuple *TemplateParams, uint32_t AlignInBits, - DINodeArray Annotations) { + unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined, + DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams, + uint32_t AlignInBits, DINodeArray Annotations) { checkGlobalVariableScope(Context); auto *GV = DIGlobalVariable::getDistinct( VMContext, cast_or_null(Context), Name, LinkageName, F, - LineNumber, Ty, IsLocalToUnit, isDefined, cast_or_null(Decl), - TemplateParams, AlignInBits, Annotations); + LineNumber, Ty, IsLocalToUnit, isDefined, + cast_or_null(Decl), TemplateParams, AlignInBits, + Annotations); if (!Expr) Expr = createExpression(); auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr); @@ -751,10 +752,9 @@ static DILocalVariable *createLocalVariable( // the only valid scopes)? DIScope *Context = getNonCompileUnitScope(Scope); - auto *Node = - DILocalVariable::get(VMContext, cast_or_null(Context), Name, - File, LineNo, Ty, ArgNo, Flags, AlignInBits, - Annotations); + auto *Node = DILocalVariable::get( + VMContext, cast_or_null(Context), Name, File, LineNo, Ty, + ArgNo, Flags, AlignInBits, Annotations); if (AlwaysPreserve) { // The optimizer may remove local variables. If there is an interest // to preserve variable info in such situation then stash it in a @@ -783,17 +783,15 @@ DILocalVariable *DIBuilder::createParameterVariable( assert(ArgNo && "Expected non-zero argument number for parameter"); return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo, File, LineNo, Ty, AlwaysPreserve, Flags, - /* AlignInBits */0, Annotations); + /*AlignInBits=*/0, Annotations); } -DILabel *DIBuilder::createLabel( - DIScope *Scope, StringRef Name, DIFile *File, - unsigned LineNo, bool AlwaysPreserve) { +DILabel *DIBuilder::createLabel(DIScope *Scope, StringRef Name, DIFile *File, + unsigned LineNo, bool AlwaysPreserve) { DIScope *Context = getNonCompileUnitScope(Scope); - auto *Node = - DILabel::get(VMContext, cast_or_null(Context), Name, - File, LineNo); + auto *Node = DILabel::get(VMContext, cast_or_null(Context), + Name, File, LineNo); if (AlwaysPreserve) { /// The optimizer may remove labels. If there is an interest @@ -817,7 +815,7 @@ DIExpression *DIBuilder::createExpression(ArrayRef Signed) { } template -static DISubprogram *getSubprogram(bool IsDistinct, Ts &&... Args) { +static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) { if (IsDistinct) return DISubprogram::getDistinct(std::forward(Args)...); return DISubprogram::get(std::forward(Args)...); @@ -881,11 +879,11 @@ DISubprogram *DIBuilder::createMethod( return SP; } -DICommonBlock *DIBuilder::createCommonBlock( - DIScope *Scope, DIGlobalVariable *Decl, StringRef Name, DIFile *File, - unsigned LineNo) { - return DICommonBlock::get( - VMContext, Scope, Decl, Name, File, LineNo); +DICommonBlock *DIBuilder::createCommonBlock(DIScope *Scope, + DIGlobalVariable *Decl, + StringRef Name, DIFile *File, + unsigned LineNo) { + return DICommonBlock::get(VMContext, Scope, Decl, Name, File, LineNo); } DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name, @@ -941,9 +939,9 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL, Instruction *InsertBefore) { - return insertLabel( - LabelInfo, DL, InsertBefore ? InsertBefore->getParent() : nullptr, - InsertBefore); + return insertLabel(LabelInfo, DL, + InsertBefore ? InsertBefore->getParent() : nullptr, + InsertBefore); } Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL, @@ -992,7 +990,8 @@ static Function *getDeclareIntrin(Module &M) { Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, - BasicBlock *InsertBB, Instruction *InsertBefore) { + BasicBlock *InsertBB, + Instruction *InsertBefore) { assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare"); assert(DL && "Expected debug loc"); assert(DL->getScope()->getSubprogram() == @@ -1035,9 +1034,9 @@ Instruction *DIBuilder::insertDbgValueIntrinsic( return B.CreateCall(ValueFn, Args); } -Instruction *DIBuilder::insertLabel( - DILabel *LabelInfo, const DILocation *DL, - BasicBlock *InsertBB, Instruction *InsertBefore) { +Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL, + BasicBlock *InsertBB, + Instruction *InsertBefore) { assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label"); assert(DL && "Expected debug loc"); assert(DL->getScope()->getSubprogram() == @@ -1054,8 +1053,7 @@ Instruction *DIBuilder::insertLabel( return B.CreateCall(LabelFn, Args); } -void DIBuilder::replaceVTableHolder(DICompositeType *&T, - DIType *VTableHolder) { +void DIBuilder::replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder) { { TypedTrackingMDRef N(T); N->replaceVTableHolder(VTableHolder); diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 66d436520ee7..b20e581d283a 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -82,8 +82,8 @@ DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line, Storage, Context.pImpl->DILocations); } -const -DILocation *DILocation::getMergedLocations(ArrayRef Locs) { +const DILocation * +DILocation::getMergedLocations(ArrayRef Locs) { if (Locs.empty()) return nullptr; if (Locs.size() == 1) @@ -139,7 +139,8 @@ const DILocation *DILocation::getMergedLocation(const DILocation *LocA, return DILocation::get(Result->getContext(), 0, 0, S, L); } -Optional DILocation::encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI) { +Optional DILocation::encodeDiscriminator(unsigned BD, unsigned DF, + unsigned CI) { std::array Components = {BD, DF, CI}; uint64_t RemainingWork = 0U; // We use RemainingWork to figure out if we have no remaining components to @@ -147,7 +148,8 @@ Optional DILocation::encodeDiscriminator(unsigned BD, unsigned DF, uns // encode anything for the latter 2. // Since any of the input components is at most 32 bits, their sum will be // less than 34 bits, and thus RemainingWork won't overflow. - RemainingWork = std::accumulate(Components.begin(), Components.end(), RemainingWork); + RemainingWork = + std::accumulate(Components.begin(), Components.end(), RemainingWork); int I = 0; unsigned Ret = 0; @@ -179,7 +181,6 @@ void DILocation::decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, getNextComponentInDiscriminator(getNextComponentInDiscriminator(D))); } - DINode::DIFlags DINode::getFlag(StringRef Flag) { return StringSwitch(Flag) #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME) @@ -546,8 +547,8 @@ DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag, DEFINE_GETIMPL_LOOKUP(DIBasicType, (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags)); Metadata *Ops[] = {nullptr, nullptr, Name}; - DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding, - Flags), Ops); + DEFINE_GETIMPL_STORE(DIBasicType, + (Tag, SizeInBits, AlignInBits, Encoding, Flags), Ops); } Optional DIBasicType::getSignedness() const { @@ -589,9 +590,10 @@ DIDerivedType *DIDerivedType::getImpl( AlignInBits, OffsetInBits, DWARFAddressSpace, Flags, ExtraData, Annotations)); Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData, Annotations}; - DEFINE_GETIMPL_STORE( - DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, - DWARFAddressSpace, Flags), Ops); + DEFINE_GETIMPL_STORE(DIDerivedType, + (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, + DWARFAddressSpace, Flags), + Ops); } DICompositeType *DICompositeType::getImpl( @@ -616,9 +618,10 @@ DICompositeType *DICompositeType::getImpl( Elements, VTableHolder, TemplateParams, Identifier, Discriminator, DataLocation, Associated, Allocated, Rank, Annotations}; - DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits, - AlignInBits, OffsetInBits, Flags), - Ops); + DEFINE_GETIMPL_STORE( + DICompositeType, + (Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits, Flags), + Ops); } DICompositeType *DICompositeType::buildODRType( @@ -798,10 +801,14 @@ DICompileUnit::getNameTableKind(StringRef Str) { const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) { switch (EK) { - case NoDebug: return "NoDebug"; - case FullDebug: return "FullDebug"; - case LineTablesOnly: return "LineTablesOnly"; - case DebugDirectivesOnly: return "DebugDirectivesOnly"; + case NoDebug: + return "NoDebug"; + case FullDebug: + return "FullDebug"; + case LineTablesOnly: + return "LineTablesOnly"; + case DebugDirectivesOnly: + return "DebugDirectivesOnly"; } return nullptr; } @@ -881,9 +888,9 @@ DISubprogram *DISubprogram::getImpl( SPFlags, Unit, TemplateParams, Declaration, RetainedNodes, ThrownTypes, Annotations)); SmallVector Ops = { - File, Scope, Name, LinkageName, Type, Unit, - Declaration, RetainedNodes, ContainingType, TemplateParams, ThrownTypes, - Annotations}; + File, Scope, Name, LinkageName, + Type, Unit, Declaration, RetainedNodes, + ContainingType, TemplateParams, ThrownTypes, Annotations}; if (!Annotations) { Ops.pop_back(); if (!ThrownTypes) { @@ -995,11 +1002,10 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, bool ShouldCreate) { assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(LinkageName) && "Expected canonical MDString"); - DEFINE_GETIMPL_LOOKUP(DIGlobalVariable, (Scope, Name, LinkageName, File, Line, - Type, IsLocalToUnit, IsDefinition, - StaticDataMemberDeclaration, - TemplateParams, AlignInBits, - Annotations)); + DEFINE_GETIMPL_LOOKUP( + DIGlobalVariable, + (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, + StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations)); Metadata *Ops[] = {Scope, Name, File, @@ -1013,22 +1019,19 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, (Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops); } -DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, - MDString *Name, Metadata *File, - unsigned Line, Metadata *Type, - unsigned Arg, DIFlags Flags, - uint32_t AlignInBits, - Metadata *Annotations, - StorageType Storage, - bool ShouldCreate) { +DILocalVariable * +DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, + Metadata *File, unsigned Line, Metadata *Type, + unsigned Arg, DIFlags Flags, uint32_t AlignInBits, + Metadata *Annotations, StorageType Storage, + bool ShouldCreate) { // 64K ought to be enough for any frontend. assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits"); assert(Scope && "Expected scope"); assert(isCanonical(Name) && "Expected canonical MDString"); - DEFINE_GETIMPL_LOOKUP(DILocalVariable, - (Scope, Name, File, Line, Type, Arg, Flags, - AlignInBits, Annotations)); + DEFINE_GETIMPL_LOOKUP(DILocalVariable, (Scope, Name, File, Line, Type, Arg, + Flags, AlignInBits, Annotations)); Metadata *Ops[] = {Scope, Name, File, Type, Annotations}; DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops); } @@ -1056,14 +1059,12 @@ Optional DIVariable::getSizeInBits() const { return None; } -DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, - MDString *Name, Metadata *File, unsigned Line, - StorageType Storage, +DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name, + Metadata *File, unsigned Line, StorageType Storage, bool ShouldCreate) { assert(Scope && "Expected scope"); assert(isCanonical(Name) && "Expected canonical MDString"); - DEFINE_GETIMPL_LOOKUP(DILabel, - (Scope, Name, File, Line)); + DEFINE_GETIMPL_LOOKUP(DILabel, (Scope, Name, File, Line)); Metadata *Ops[] = {Scope, Name, File}; DEFINE_GETIMPL_STORE(DILabel, (Line), Ops); } @@ -1212,10 +1213,11 @@ bool DIExpression::isComplex() const { // kind of complex computation occurs. for (const auto &It : expr_ops()) { switch (It.getOp()) { - case dwarf::DW_OP_LLVM_tag_offset: - case dwarf::DW_OP_LLVM_fragment: - continue; - default: return true; + case dwarf::DW_OP_LLVM_tag_offset: + case dwarf::DW_OP_LLVM_fragment: + continue; + default: + return true; } } @@ -1364,8 +1366,7 @@ DIExpression *DIExpression::replaceArg(const DIExpression *Expr, DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr, SmallVectorImpl &Ops, - bool StackValue, - bool EntryValue) { + bool StackValue, bool EntryValue) { assert(Expr && "Can't prepend ops to this expression"); if (EntryValue) { @@ -1460,7 +1461,8 @@ Optional DIExpression::createFragmentExpression( if (Expr) { for (auto Op : Expr->expr_ops()) { switch (Op.getOp()) { - default: break; + default: + break; case dwarf::DW_OP_shr: case dwarf::DW_OP_shra: case dwarf::DW_OP_shl: @@ -1619,12 +1621,12 @@ DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag, DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops); } -DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, - unsigned Line, MDString *Name, MDString *Value, - StorageType Storage, bool ShouldCreate) { +DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, unsigned Line, + MDString *Name, MDString *Value, StorageType Storage, + bool ShouldCreate) { assert(isCanonical(Name) && "Expected canonical MDString"); DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value)); - Metadata *Ops[] = { Name, Value }; + Metadata *Ops[] = {Name, Value}; DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops); } @@ -1632,9 +1634,8 @@ DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType, unsigned Line, Metadata *File, Metadata *Elements, StorageType Storage, bool ShouldCreate) { - DEFINE_GETIMPL_LOOKUP(DIMacroFile, - (MIType, Line, File, Elements)); - Metadata *Ops[] = { File, Elements }; + DEFINE_GETIMPL_LOOKUP(DIMacroFile, (MIType, Line, File, Elements)); + Metadata *Ops[] = {File, Elements}; DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops); } diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index d84714d9b1f1..b2909c425846 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -61,7 +61,9 @@ using DenseMapAPIntKeyInfo = DenseMapInfo; struct DenseMapAPFloatKeyInfo { static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); } - static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); } + static inline APFloat getTombstoneKey() { + return APFloat(APFloat::Bogus(), 2); + } static unsigned getHashValue(const APFloat &Key) { return static_cast(hash_value(Key)); @@ -74,46 +76,42 @@ struct DenseMapAPFloatKeyInfo { struct AnonStructTypeKeyInfo { struct KeyTy { - ArrayRef ETypes; + ArrayRef ETypes; bool isPacked; - KeyTy(const ArrayRef& E, bool P) : - ETypes(E), isPacked(P) {} + KeyTy(const ArrayRef &E, bool P) : ETypes(E), isPacked(P) {} KeyTy(const StructType *ST) : ETypes(ST->elements()), isPacked(ST->isPacked()) {} - bool operator==(const KeyTy& that) const { + bool operator==(const KeyTy &that) const { if (isPacked != that.isPacked) return false; if (ETypes != that.ETypes) return false; return true; } - bool operator!=(const KeyTy& that) const { - return !this->operator==(that); - } + bool operator!=(const KeyTy &that) const { return !this->operator==(that); } }; - static inline StructType* getEmptyKey() { - return DenseMapInfo::getEmptyKey(); + static inline StructType *getEmptyKey() { + return DenseMapInfo::getEmptyKey(); } - static inline StructType* getTombstoneKey() { - return DenseMapInfo::getTombstoneKey(); + static inline StructType *getTombstoneKey() { + return DenseMapInfo::getTombstoneKey(); } - static unsigned getHashValue(const KeyTy& Key) { - return hash_combine(hash_combine_range(Key.ETypes.begin(), - Key.ETypes.end()), - Key.isPacked); + static unsigned getHashValue(const KeyTy &Key) { + return hash_combine( + hash_combine_range(Key.ETypes.begin(), Key.ETypes.end()), Key.isPacked); } static unsigned getHashValue(const StructType *ST) { return getHashValue(KeyTy(ST)); } - static bool isEqual(const KeyTy& LHS, const StructType *RHS) { + static bool isEqual(const KeyTy &LHS, const StructType *RHS) { if (RHS == getEmptyKey() || RHS == getTombstoneKey()) return false; return LHS == KeyTy(RHS); @@ -127,16 +125,16 @@ struct AnonStructTypeKeyInfo { struct FunctionTypeKeyInfo { struct KeyTy { const Type *ReturnType; - ArrayRef Params; + ArrayRef Params; bool isVarArg; - KeyTy(const Type* R, const ArrayRef& P, bool V) : - ReturnType(R), Params(P), isVarArg(V) {} + KeyTy(const Type *R, const ArrayRef &P, bool V) + : ReturnType(R), Params(P), isVarArg(V) {} KeyTy(const FunctionType *FT) : ReturnType(FT->getReturnType()), Params(FT->params()), isVarArg(FT->isVarArg()) {} - bool operator==(const KeyTy& that) const { + bool operator==(const KeyTy &that) const { if (ReturnType != that.ReturnType) return false; if (isVarArg != that.isVarArg) @@ -145,31 +143,28 @@ struct FunctionTypeKeyInfo { return false; return true; } - bool operator!=(const KeyTy& that) const { - return !this->operator==(that); - } + bool operator!=(const KeyTy &that) const { return !this->operator==(that); } }; - static inline FunctionType* getEmptyKey() { - return DenseMapInfo::getEmptyKey(); + static inline FunctionType *getEmptyKey() { + return DenseMapInfo::getEmptyKey(); } - static inline FunctionType* getTombstoneKey() { - return DenseMapInfo::getTombstoneKey(); + static inline FunctionType *getTombstoneKey() { + return DenseMapInfo::getTombstoneKey(); } - static unsigned getHashValue(const KeyTy& Key) { - return hash_combine(Key.ReturnType, - hash_combine_range(Key.Params.begin(), - Key.Params.end()), - Key.isVarArg); + static unsigned getHashValue(const KeyTy &Key) { + return hash_combine( + Key.ReturnType, + hash_combine_range(Key.Params.begin(), Key.Params.end()), Key.isVarArg); } static unsigned getHashValue(const FunctionType *FT) { return getHashValue(KeyTy(FT)); } - static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) { + static bool isEqual(const KeyTy &LHS, const FunctionType *RHS) { if (RHS == getEmptyKey() || RHS == getTombstoneKey()) return false; return LHS == KeyTy(RHS); @@ -412,14 +407,14 @@ template <> struct MDNodeKeyImpl { Encoding(Encoding), Flags(Flags) {} MDNodeKeyImpl(const DIBasicType *N) : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()), - AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()), Flags(N->getFlags()) {} + AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()), + Flags(N->getFlags()) {} bool isKeyOf(const DIBasicType *RHS) const { return Tag == RHS->getTag() && Name == RHS->getRawName() && SizeInBits == RHS->getSizeInBits() && AlignInBits == RHS->getAlignInBits() && - Encoding == RHS->getEncoding() && - Flags == RHS->getFlags(); + Encoding == RHS->getEncoding() && Flags == RHS->getFlags(); } unsigned getHashValue() const { @@ -526,7 +521,8 @@ template <> struct MDNodeSubsetEqualImpl { return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS); } - static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS) { + static bool isSubsetEqual(const DIDerivedType *LHS, + const DIDerivedType *RHS) { return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(), RHS); } @@ -667,14 +663,13 @@ template <> struct MDNodeKeyImpl { bool isKeyOf(const DIFile *RHS) const { return Filename == RHS->getRawFilename() && Directory == RHS->getRawDirectory() && - Checksum == RHS->getRawChecksum() && - Source == RHS->getRawSource(); + Checksum == RHS->getRawChecksum() && Source == RHS->getRawSource(); } unsigned getHashValue() const { - return hash_combine( - Filename, Directory, Checksum ? Checksum->Kind : 0, - Checksum ? Checksum->Value : nullptr, Source.getValueOr(nullptr)); + return hash_combine(Filename, Directory, Checksum ? Checksum->Kind : 0, + Checksum ? Checksum->Value : nullptr, + Source.getValueOr(nullptr)); } }; @@ -723,8 +718,8 @@ template <> struct MDNodeKeyImpl { TemplateParams(N->getRawTemplateParams()), Declaration(N->getRawDeclaration()), RetainedNodes(N->getRawRetainedNodes()), - ThrownTypes(N->getRawThrownTypes()), Annotations(N->getRawAnnotations()) - {} + ThrownTypes(N->getRawThrownTypes()), + Annotations(N->getRawAnnotations()) {} bool isKeyOf(const DISubprogram *RHS) const { return Scope == RHS->getRawScope() && Name == RHS->getRawName() && @@ -861,9 +856,7 @@ template <> struct MDNodeKeyImpl { ExportSymbols == RHS->getExportSymbols(); } - unsigned getHashValue() const { - return hash_combine(Scope, Name); - } + unsigned getHashValue() const { return hash_combine(Scope, Name); } }; template <> struct MDNodeKeyImpl { @@ -873,8 +866,8 @@ template <> struct MDNodeKeyImpl { Metadata *File; unsigned LineNo; - MDNodeKeyImpl(Metadata *Scope, Metadata *Decl, MDString *Name, - Metadata *File, unsigned LineNo) + MDNodeKeyImpl(Metadata *Scope, Metadata *Decl, MDString *Name, Metadata *File, + unsigned LineNo) : Scope(Scope), Decl(Decl), Name(Name), File(File), LineNo(LineNo) {} MDNodeKeyImpl(const DICommonBlock *N) : Scope(N->getRawScope()), Decl(N->getRawDecl()), Name(N->getRawName()), @@ -882,8 +875,8 @@ template <> struct MDNodeKeyImpl { bool isKeyOf(const DICommonBlock *RHS) const { return Scope == RHS->getRawScope() && Decl == RHS->getRawDecl() && - Name == RHS->getRawName() && File == RHS->getRawFile() && - LineNo == RHS->getLineNo(); + Name == RHS->getRawName() && File == RHS->getRawFile() && + LineNo == RHS->getLineNo(); } unsigned getHashValue() const { @@ -1093,9 +1086,7 @@ template <> struct MDNodeKeyImpl { } /// Using name and line to get hash value. It should already be mostly unique. - unsigned getHashValue() const { - return hash_combine(Scope, Name, Line); - } + unsigned getHashValue() const { return hash_combine(Scope, Name, Line); } }; template <> struct MDNodeKeyImpl { @@ -1342,7 +1333,7 @@ class LLVMContextImpl { public: /// OwnedModules - The set of modules instantiated in this context, and which /// will be automatically deleted if this context is deleted. - SmallPtrSet OwnedModules; + SmallPtrSet OwnedModules; /// The main remark streamer used by all the other streamers (e.g. IR, MIR, /// frontends, etc.). This should only be used by the specific streamers, and @@ -1394,7 +1385,7 @@ public: DenseMap ValuesAsMetadata; DenseMap MetadataAsValues; - DenseMap ValueNames; + DenseMap ValueNames; #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ DenseSet CLASS##s; @@ -1429,7 +1420,7 @@ public: StringMap> CDSConstants; DenseMap, BlockAddress *> - BlockAddresses; + BlockAddresses; DenseMap DSOLocalEquivalents; @@ -1451,19 +1442,19 @@ public: BumpPtrAllocator Alloc; UniqueStringSaver Saver{Alloc}; - DenseMap IntegerTypes; + DenseMap IntegerTypes; using FunctionTypeSet = DenseSet; FunctionTypeSet FunctionTypes; using StructTypeSet = DenseSet; StructTypeSet AnonStructTypes; - StringMap NamedStructTypes; + StringMap NamedStructTypes; unsigned NamedStructTypesUniqueID = 0; - DenseMap, ArrayType*> ArrayTypes; + DenseMap, ArrayType *> ArrayTypes; DenseMap, VectorType *> VectorTypes; - DenseMap PointerTypes; // Pointers in AddrSpace = 0 - DenseMap, PointerType*> ASPointerTypes; + DenseMap PointerTypes; // Pointers in AddrSpace = 0 + DenseMap, PointerType *> ASPointerTypes; /// ValueHandles - This map keeps track of all of the value handles that are /// watching a Value*. The Value::HasValueHandle bit is used to know @@ -1517,7 +1508,7 @@ public: /// This saves allocating an additional word in Function for programs which /// do not use GC (i.e., most programs) at the cost of increased overhead for /// clients which do use GC. - DenseMap GCNames; + DenseMap GCNames; /// Flag to indicate if Value (other than GlobalValue) retains their name or /// not. @@ -1540,7 +1531,7 @@ public: /// /// The lifetime of the object must be guaranteed to extend as long as the /// LLVMContext is used by compilation. - void setOptPassGate(OptPassGate&); + void setOptPassGate(OptPassGate &); // TODO: clean up the following after we no longer support non-opaque pointer // types.