diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -256,11 +256,13 @@ 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 @@ 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 @@ 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 @@ }; /// 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 @@ 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 @@ } 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 @@ 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 @@ } 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 @@ /// 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 @@ 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 @@ 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 @@ /// 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 @@ /// 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 @@ /// 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,13 @@ /// 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 - /// \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); + /// 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); /// Raw decoder for values in an encoded discriminator D. static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, @@ -1799,11 +1801,10 @@ /// 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 +1858,10 @@ 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 +1902,14 @@ 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 +1962,10 @@ 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 +2141,13 @@ } 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 +2192,9 @@ } 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 +2308,10 @@ 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 +2460,7 @@ (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 +2853,8 @@ /// \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 +2993,22 @@ } 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 +3043,20 @@ 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 +3065,11 @@ 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 +3116,18 @@ 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 +3144,8 @@ 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 +3197,14 @@ : 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 +3517,13 @@ } 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 +3570,13 @@ } 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 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -362,7 +362,8 @@ 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 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ // 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 @@ 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 @@ 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 @@ 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 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -32,8 +32,8 @@ 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 @@ 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::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 @@ 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( @@ -503,10 +501,12 @@ 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 @@ 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::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 @@ 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 @@ // 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 @@ 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 @@ } 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 @@ 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::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 @@ 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 @@ 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 @@ 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 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -82,8 +82,8 @@ 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 @@ 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 @@ // 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ (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 @@ 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 @@ // 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::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 @@ 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 @@ 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 @@ 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 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -61,7 +61,9 @@ 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 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 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } /// 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 @@ 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 @@ DenseMap ValuesAsMetadata; DenseMap MetadataAsValues; - DenseMap ValueNames; + DenseMap ValueNames; #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ DenseSet CLASS##s; @@ -1429,7 +1420,7 @@ StringMap> CDSConstants; DenseMap, BlockAddress *> - BlockAddresses; + BlockAddresses; DenseMap DSOLocalEquivalents; @@ -1451,19 +1442,19 @@ 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 @@ /// 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 @@ /// /// 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.