diff --git a/llvm/include/llvm/DebugInfo/BTF/BTF.h b/llvm/include/llvm/DebugInfo/BTF/BTF.h index d88af2ff30bdf..bd666e4202985 100644 --- a/llvm/include/llvm/DebugInfo/BTF/BTF.h +++ b/llvm/include/llvm/DebugInfo/BTF/BTF.h @@ -304,14 +304,12 @@ enum PatchableRelocKind : uint32_t { // For CommonType sub-types that are followed by a single entry of // some type in the binary format. #define BTF_DEFINE_TAIL(Type, Accessor) \ - const Type &Accessor() const { return *getTrailingObjects(); } + const Type &Accessor() const { return *getTrailingObjects(); } // For CommonType sub-types that are followed by CommonType::getVlen() // number of entries of some type in the binary format. #define BTF_DEFINE_TAIL_ARR(Type, Accessor) \ - ArrayRef Accessor() const { \ - return ArrayRef(getTrailingObjects(), getVlen()); \ - } + ArrayRef Accessor() const { return getTrailingObjects(getVlen()); } struct ArrayType final : CommonType, private TrailingObjects { diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h index 2ad080e6d0cd2..d83fe1299237b 100644 --- a/llvm/include/llvm/IR/DataLayout.h +++ b/llvm/include/llvm/IR/DataLayout.h @@ -564,7 +564,9 @@ inline LLVMTargetDataRef wrap(const DataLayout *P) { /// Used to lazily calculate structure layout information for a target machine, /// based on the DataLayout structure. -class StructLayout final : public TrailingObjects { +class StructLayout final : private TrailingObjects { + friend TrailingObjects; + TypeSize StructSize; Align StructAlignment; unsigned IsPadded : 1; @@ -586,11 +588,11 @@ class StructLayout final : public TrailingObjects { unsigned getElementContainingOffset(uint64_t FixedOffset) const; MutableArrayRef getMemberOffsets() { - return llvm::MutableArrayRef(getTrailingObjects(), NumElements); + return getTrailingObjects(NumElements); } ArrayRef getMemberOffsets() const { - return llvm::ArrayRef(getTrailingObjects(), NumElements); + return getTrailingObjects(NumElements); } TypeSize getElementOffset(unsigned Idx) const { @@ -606,10 +608,6 @@ class StructLayout final : public TrailingObjects { friend class DataLayout; // Only DataLayout can create this class StructLayout(StructType *ST, const DataLayout &DL); - - size_t numTrailingObjects(OverloadToken) const { - return NumElements; - } }; // The implementation of this method is provided inline as it is particularly diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index 982cc255553a2..687980cf5e0e4 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -258,7 +258,7 @@ class RecordRecTy final : public RecTy, void Profile(FoldingSetNodeID &ID) const; ArrayRef getClasses() const { - return ArrayRef(getTrailingObjects(), NumClasses); + return getTrailingObjects(NumClasses); } using const_record_iterator = const Record *const *; @@ -632,9 +632,7 @@ class BitsInit final : public TypedInit, const Init *resolveReferences(Resolver &R) const override; - ArrayRef getBits() const { - return ArrayRef(getTrailingObjects(), NumBits); - } + ArrayRef getBits() const { return getTrailingObjects(NumBits); } const Init *getBit(unsigned Bit) const override { return getBits()[Bit]; } }; @@ -783,7 +781,7 @@ class ListInit final : public TypedInit, void Profile(FoldingSetNodeID &ID) const; ArrayRef getValues() const { - return ArrayRef(getTrailingObjects(), NumValues); + return ArrayRef(getTrailingObjects(), NumValues); } const Init *getElement(unsigned Index) const { return getValues()[Index]; } @@ -1026,10 +1024,6 @@ class CondOpInit final : public TypedInit, CondOpInit(ArrayRef Conds, ArrayRef Values, const RecTy *Type); - size_t numTrailingObjects(OverloadToken) const { - return 2*NumConds; - } - public: CondOpInit(const CondOpInit &) = delete; CondOpInit &operator=(const CondOpInit &) = delete; @@ -1053,11 +1047,11 @@ class CondOpInit final : public TypedInit, const Init *getVal(unsigned Num) const { return getVals()[Num]; } ArrayRef getConds() const { - return ArrayRef(getTrailingObjects(), NumConds); + return getTrailingObjects(NumConds); } ArrayRef getVals() const { - return ArrayRef(getTrailingObjects() + NumConds, NumConds); + return ArrayRef(getTrailingObjects() + NumConds, NumConds); } const Init *Fold(const Record *CurRec) const; @@ -1375,7 +1369,7 @@ class VarDefInit final bool args_empty() const { return NumArgs == 0; } ArrayRef args() const { - return ArrayRef(getTrailingObjects(), NumArgs); + return getTrailingObjects(NumArgs); } const Init *getBit(unsigned Bit) const override { @@ -1488,11 +1482,11 @@ class DagInit final } ArrayRef getArgs() const { - return ArrayRef(getTrailingObjects(), NumArgs); + return getTrailingObjects(NumArgs); } ArrayRef getArgNames() const { - return ArrayRef(getTrailingObjects(), NumArgs); + return getTrailingObjects(NumArgs); } const Init *resolveReferences(Resolver &R) const override; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 1e07f060d72cb..64f963814e1cc 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -542,7 +542,7 @@ class BitcodeConstant final : public Value, : Value(Ty, SubclassID), Opcode(Info.Opcode), Flags(Info.Flags), NumOperands(OpIDs.size()), BlockAddressBB(Info.BlockAddressBB), SrcElemTy(Info.SrcElemTy), InRange(Info.InRange) { - llvm::uninitialized_copy(OpIDs, getTrailingObjects()); + llvm::uninitialized_copy(OpIDs, getTrailingObjects()); } BitcodeConstant &operator=(const BitcodeConstant &) = delete; @@ -559,7 +559,7 @@ class BitcodeConstant final : public Value, static bool classof(const Value *V) { return V->getValueID() == SubclassID; } ArrayRef getOperandIDs() const { - return ArrayRef(getTrailingObjects(), NumOperands); + return ArrayRef(getTrailingObjects(), NumOperands); } std::optional getInRange() const { diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h index 98d1bad7680ab..707c8205ee1f9 100644 --- a/llvm/lib/IR/AttributeImpl.h +++ b/llvm/lib/IR/AttributeImpl.h @@ -195,15 +195,12 @@ class StringAttributeImpl final unsigned KindSize; unsigned ValSize; - size_t numTrailingObjects(OverloadToken) const { - return KindSize + 1 + ValSize + 1; - } public: StringAttributeImpl(StringRef Kind, StringRef Val = StringRef()) : AttributeImpl(StringAttrEntry), KindSize(Kind.size()), ValSize(Val.size()) { - char *TrailingString = getTrailingObjects(); + char *TrailingString = getTrailingObjects(); // Some users rely on zero-termination. llvm::copy(Kind, TrailingString); TrailingString[KindSize] = '\0'; @@ -212,10 +209,10 @@ class StringAttributeImpl final } StringRef getStringKind() const { - return StringRef(getTrailingObjects(), KindSize); + return StringRef(getTrailingObjects(), KindSize); } StringRef getStringValue() const { - return StringRef(getTrailingObjects() + KindSize + 1, ValSize); + return StringRef(getTrailingObjects() + KindSize + 1, ValSize); } static size_t totalSizeToAlloc(StringRef Kind, StringRef Val) { @@ -250,25 +247,22 @@ class ConstantRangeListAttributeImpl final friend TrailingObjects; unsigned Size; - size_t numTrailingObjects(OverloadToken) const { return Size; } public: ConstantRangeListAttributeImpl(Attribute::AttrKind Kind, ArrayRef Val) : EnumAttributeImpl(ConstantRangeListAttrEntry, Kind), Size(Val.size()) { assert(Size > 0); - ConstantRange *TrailingCR = getTrailingObjects(); - llvm::uninitialized_copy(Val, TrailingCR); + llvm::uninitialized_copy(Val, getTrailingObjects()); } ~ConstantRangeListAttributeImpl() { - ConstantRange *TrailingCR = getTrailingObjects(); - for (unsigned I = 0; I != Size; ++I) - TrailingCR[I].~ConstantRange(); + for (ConstantRange &CR : getTrailingObjects(Size)) + CR.~ConstantRange(); } ArrayRef getConstantRangeListValue() const { - return ArrayRef(getTrailingObjects(), Size); + return getTrailingObjects(Size); } static size_t totalSizeToAlloc(ArrayRef Val) { @@ -353,7 +347,7 @@ class AttributeSetNode final using iterator = const Attribute *; - iterator begin() const { return getTrailingObjects(); } + iterator begin() const { return getTrailingObjects(); } iterator end() const { return begin() + NumAttrs; } void Profile(FoldingSetNodeID &ID) const { @@ -383,9 +377,6 @@ class AttributeListImpl final /// Union of enum attributes available at any index. AttributeBitSet AvailableSomewhereAttrs; - // Helper fn for TrailingObjects class. - size_t numTrailingObjects(OverloadToken) { return NumAttrSets; } - public: AttributeListImpl(ArrayRef Sets); @@ -407,7 +398,7 @@ class AttributeListImpl final using iterator = const AttributeSet *; - iterator begin() const { return getTrailingObjects(); } + iterator begin() const { return getTrailingObjects(); } iterator end() const { return begin() + NumAttrSets; } void Profile(FoldingSetNodeID &ID) const; diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index 33ac8bfaf4e7c..5b0ceb34381a9 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1237,7 +1237,7 @@ LLVM_DUMP_METHOD void AttributeSet::dump() const { AttributeSetNode::AttributeSetNode(ArrayRef Attrs) : NumAttrs(Attrs.size()) { // There's memory after the node where we can store the entries in. - llvm::copy(Attrs, getTrailingObjects()); + llvm::copy(Attrs, getTrailingObjects()); for (const auto &I : *this) { if (I.isStringAttribute()) @@ -1423,7 +1423,7 @@ AttributeListImpl::AttributeListImpl(ArrayRef Sets) assert(!Sets.empty() && "pointless AttributeListImpl"); // There's memory after the node where we can store the entries in. - llvm::copy(Sets, getTrailingObjects()); + llvm::copy(Sets, getTrailingObjects()); // Initialize AvailableFunctionAttrs and AvailableSomewhereAttrs // summary bitsets. diff --git a/llvm/lib/Support/TrieRawHashMap.cpp b/llvm/lib/Support/TrieRawHashMap.cpp index 11d79a62d011d..bb779fe87ae62 100644 --- a/llvm/lib/Support/TrieRawHashMap.cpp +++ b/llvm/lib/Support/TrieRawHashMap.cpp @@ -62,7 +62,7 @@ class TrieSubtrie final public: using Slot = LazyAtomicPointer; - Slot &get(size_t I) { return getTrailingObjects()[I]; } + Slot &get(size_t I) { return getTrailingObjects()[I]; } TrieNode *load(size_t I) { return get(I).load(); } unsigned size() const { return Size; } @@ -190,7 +190,7 @@ class ThreadSafeTrieRawHashMapBase::ImplType final } // Get the root which is the trailing object. - TrieSubtrie *getRoot() { return getTrailingObjects(); } + TrieSubtrie *getRoot() { return getTrailingObjects(); } static void *operator new(size_t Size) { return ::operator new(Size); } void operator delete(void *Ptr) { ::operator delete(Ptr); } diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index f3d54e6083e48..e09ea4902fa5d 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -240,7 +240,7 @@ static void ProfileRecordRecTy(FoldingSetNodeID &ID, RecordRecTy::RecordRecTy(RecordKeeper &RK, ArrayRef Classes) : RecTy(RecordRecTyKind, RK), NumClasses(Classes.size()) { - llvm::uninitialized_copy(Classes, getTrailingObjects()); + llvm::uninitialized_copy(Classes, getTrailingObjects()); } const RecordRecTy *RecordRecTy::get(RecordKeeper &RK, @@ -473,7 +473,7 @@ static void ProfileBitsInit(FoldingSetNodeID &ID, BitsInit::BitsInit(RecordKeeper &RK, ArrayRef Bits) : TypedInit(IK_BitsInit, BitsRecTy::get(RK, Bits.size())), NumBits(Bits.size()) { - llvm::uninitialized_copy(Bits, getTrailingObjects()); + llvm::uninitialized_copy(Bits, getTrailingObjects()); } BitsInit *BitsInit::get(RecordKeeper &RK, ArrayRef Bits) { @@ -493,7 +493,7 @@ BitsInit *BitsInit::get(RecordKeeper &RK, ArrayRef Bits) { } void BitsInit::Profile(FoldingSetNodeID &ID) const { - ProfileBitsInit(ID, ArrayRef(getTrailingObjects(), NumBits)); + ProfileBitsInit(ID, getBits()); } const Init *BitsInit::convertInitializerTo(const RecTy *Ty) const { @@ -706,7 +706,7 @@ static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef Range, ListInit::ListInit(ArrayRef Elements, const RecTy *EltTy) : TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(Elements.size()) { - llvm::uninitialized_copy(Elements, getTrailingObjects()); + llvm::uninitialized_copy(Elements, getTrailingObjects()); } const ListInit *ListInit::get(ArrayRef Elements, @@ -2432,7 +2432,7 @@ VarDefInit::VarDefInit(SMLoc Loc, const Record *Class, ArrayRef Args) : TypedInit(IK_VarDefInit, RecordRecTy::get(Class)), Loc(Loc), Class(Class), NumArgs(Args.size()) { - llvm::uninitialized_copy(Args, getTrailingObjects()); + llvm::uninitialized_copy(Args, getTrailingObjects()); } const VarDefInit *VarDefInit::get(SMLoc Loc, const Record *Class, @@ -2616,7 +2616,7 @@ static void ProfileCondOpInit(FoldingSetNodeID &ID, CondOpInit::CondOpInit(ArrayRef Conds, ArrayRef Values, const RecTy *Type) : TypedInit(IK_CondOpInit, Type), NumConds(Conds.size()), ValType(Type) { - auto *TrailingObjects = getTrailingObjects(); + const Init **TrailingObjects = getTrailingObjects(); llvm::uninitialized_copy(Conds, TrailingObjects); llvm::uninitialized_copy(Values, TrailingObjects + NumConds); } diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index d855647095550..ebabece067db2 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -285,8 +285,6 @@ class GlobalTypeMember final : TrailingObjects { // module and its jumptable entry needs to be exported to thinlto backends. bool IsExported; - size_t numTrailingObjects(OverloadToken) const { return NTypes; } - public: static GlobalTypeMember *create(BumpPtrAllocator &Alloc, GlobalObject *GO, bool IsJumpTableCanonical, bool IsExported, @@ -297,7 +295,7 @@ class GlobalTypeMember final : TrailingObjects { GTM->NTypes = Types.size(); GTM->IsJumpTableCanonical = IsJumpTableCanonical; GTM->IsExported = IsExported; - llvm::copy(Types, GTM->getTrailingObjects()); + llvm::copy(Types, GTM->getTrailingObjects()); return GTM; } @@ -313,9 +311,7 @@ class GlobalTypeMember final : TrailingObjects { return IsExported; } - ArrayRef types() const { - return ArrayRef(getTrailingObjects(), NTypes); - } + ArrayRef types() const { return getTrailingObjects(NTypes); } }; struct ICallBranchFunnel final @@ -329,13 +325,13 @@ struct ICallBranchFunnel final Call->CI = CI; Call->UniqueId = UniqueId; Call->NTargets = Targets.size(); - llvm::copy(Targets, Call->getTrailingObjects()); + llvm::copy(Targets, Call->getTrailingObjects()); return Call; } CallInst *CI; ArrayRef targets() const { - return ArrayRef(getTrailingObjects(), NTargets); + return getTrailingObjects(NTargets); } unsigned UniqueId; diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 95d944170732e..68ab1527b480a 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -679,8 +679,7 @@ class alignas(8) Operation final if (numRegions == 0) return MutableArrayRef(); - auto *regions = getTrailingObjects(); - return {regions, numRegions}; + return getTrailingObjects(numRegions); } /// Returns the region held by this operation at position 'index'. @@ -694,7 +693,7 @@ class alignas(8) Operation final //===--------------------------------------------------------------------===// MutableArrayRef getBlockOperands() { - return {getTrailingObjects(), numSuccs}; + return getTrailingObjects(numSuccs); } // Successor iteration. diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h index f174ac2f476f6..9ad94839890b7 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -183,10 +183,10 @@ class CompoundStmt final : public Node::NodeBase, /// Return the children of this compound statement. MutableArrayRef getChildren() { - return {getTrailingObjects(), numChildren}; + return getTrailingObjects(numChildren); } ArrayRef getChildren() const { - return const_cast(this)->getChildren(); + return getTrailingObjects(numChildren); } ArrayRef::iterator begin() const { return getChildren().begin(); } ArrayRef::iterator end() const { return getChildren().end(); } @@ -275,10 +275,10 @@ class ReplaceStmt final : public Node::NodeBase, /// Return the replacement values of this statement. MutableArrayRef getReplExprs() { - return {getTrailingObjects(), numReplExprs}; + return getTrailingObjects(numReplExprs); } ArrayRef getReplExprs() const { - return const_cast(this)->getReplExprs(); + return getTrailingObjects(numReplExprs); } private: @@ -400,12 +400,8 @@ class CallExpr final : public Node::NodeBase, Expr *getCallableExpr() const { return callable; } /// Return the arguments of this call. - MutableArrayRef getArguments() { - return {getTrailingObjects(), numArgs}; - } - ArrayRef getArguments() const { - return const_cast(this)->getArguments(); - } + MutableArrayRef getArguments() { return getTrailingObjects(numArgs); } + ArrayRef getArguments() const { return getTrailingObjects(numArgs); } /// Returns whether the result of this call is to be negated. bool getIsNegated() const { return isNegated; } @@ -534,10 +530,10 @@ class OperationExpr final /// Return the operands of this operation. MutableArrayRef getOperands() { - return {getTrailingObjects(), numOperands}; + return getTrailingObjects(numOperands); } ArrayRef getOperands() const { - return const_cast(this)->getOperands(); + return getTrailingObjects(numOperands); } /// Return the result types of this operation. @@ -550,10 +546,10 @@ class OperationExpr final /// Return the attributes of this operation. MutableArrayRef getAttributes() { - return {getTrailingObjects(), numAttributes}; + return getTrailingObjects(numAttributes); } - MutableArrayRef getAttributes() const { - return const_cast(this)->getAttributes(); + ArrayRef getAttributes() const { + return getTrailingObjects(numAttributes); } private: @@ -594,10 +590,10 @@ class RangeExpr final : public Node::NodeBase, /// Return the element expressions of this range. MutableArrayRef getElements() { - return {getTrailingObjects(), numElements}; + return getTrailingObjects(numElements); } ArrayRef getElements() const { - return const_cast(this)->getElements(); + return getTrailingObjects(numElements); } /// Return the range result type of this expression. @@ -627,10 +623,10 @@ class TupleExpr final : public Node::NodeBase, /// Return the element expressions of this tuple. MutableArrayRef getElements() { - return {getTrailingObjects(), getType().size()}; + return getTrailingObjects(getType().size()); } ArrayRef getElements() const { - return const_cast(this)->getElements(); + return getTrailingObjects(getType().size()); } /// Return the tuple result type of this expression. @@ -916,10 +912,10 @@ class UserConstraintDecl final /// Return the input arguments of this constraint. MutableArrayRef getInputs() { - return {getTrailingObjects(), numInputs}; + return getTrailingObjects(numInputs); } ArrayRef getInputs() const { - return const_cast(this)->getInputs(); + return getTrailingObjects(numInputs); } /// Return the explicit native type to use for the given input. Returns @@ -1126,16 +1122,16 @@ class UserRewriteDecl final /// Return the input arguments of this rewrite. MutableArrayRef getInputs() { - return {getTrailingObjects(), numInputs}; + return getTrailingObjects(numInputs); } ArrayRef getInputs() const { - return const_cast(this)->getInputs(); + return getTrailingObjects(numInputs); } /// Return the explicit results of the rewrite declaration. May be empty, /// even if the rewrite has results (e.g. in the case of inferred results). MutableArrayRef getResults() { - return {getTrailingObjects() + numInputs, numResults}; + return {getTrailingObjects() + numInputs, numResults}; } ArrayRef getResults() const { return const_cast(this)->getResults(); @@ -1257,10 +1253,10 @@ class VariableDecl final /// Return the constraints of this variable. MutableArrayRef getConstraints() { - return {getTrailingObjects(), numConstraints}; + return getTrailingObjects(numConstraints); } ArrayRef getConstraints() const { - return const_cast(this)->getConstraints(); + return getTrailingObjects(numConstraints); } /// Return the initializer expression of this statement, or nullptr if there @@ -1304,10 +1300,10 @@ class Module final : public Node::NodeBase, /// Return the children of this module. MutableArrayRef getChildren() { - return {getTrailingObjects(), numChildren}; + return getTrailingObjects(numChildren); } ArrayRef getChildren() const { - return const_cast(this)->getChildren(); + return getTrailingObjects(numChildren); } private: diff --git a/mlir/lib/IR/AffineMapDetail.h b/mlir/lib/IR/AffineMapDetail.h index 32c9734f23a36..b306462357a97 100644 --- a/mlir/lib/IR/AffineMapDetail.h +++ b/mlir/lib/IR/AffineMapDetail.h @@ -24,7 +24,9 @@ namespace detail { struct AffineMapStorage final : public StorageUniquer::BaseStorage, - public llvm::TrailingObjects { + private llvm::TrailingObjects { + friend llvm::TrailingObjects; + /// The hash key used for uniquing. using KeyTy = std::tuple>; @@ -36,7 +38,7 @@ struct AffineMapStorage final /// The affine expressions for this (multi-dimensional) map. ArrayRef results() const { - return {getTrailingObjects(), numResults}; + return getTrailingObjects(numResults); } bool operator==(const KeyTy &key) const { @@ -56,7 +58,7 @@ struct AffineMapStorage final res->numDims = std::get<0>(key); res->numSymbols = std::get<1>(key); res->numResults = results.size(); - llvm::uninitialized_copy(results, res->getTrailingObjects()); + llvm::uninitialized_copy(results, res->getTrailingObjects()); return res; } }; diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp index 8ae33022be24f..f897546f36ba7 100644 --- a/mlir/lib/IR/Location.cpp +++ b/mlir/lib/IR/Location.cpp @@ -34,7 +34,8 @@ using namespace mlir::detail; namespace mlir::detail { struct FileLineColRangeAttrStorage final : public ::mlir::AttributeStorage, - public llvm::TrailingObjects { + private llvm::TrailingObjects { + friend llvm::TrailingObjects; using PointerPair = llvm::PointerIntPair; using KeyTy = std::tuple>; @@ -62,7 +63,7 @@ struct FileLineColRangeAttrStorage final result->startLine = elements[0]; // Copy in the element types into the trailing storage. llvm::uninitialized_copy(elements.drop_front(), - result->getTrailingObjects()); + result->getTrailingObjects()); } return result; } @@ -74,12 +75,12 @@ struct FileLineColRangeAttrStorage final return (filenameAndTrailing.getPointer() == std::get<0>(tblgenKey)) && (size() == std::get<1>(tblgenKey).size()) && (startLine == std::get<1>(tblgenKey)[0]) && - (ArrayRef{getTrailingObjects(), size() - 1} == - ArrayRef{std::get<1>(tblgenKey)}.drop_front()); + (getTrailingObjects(size() - 1) == + std::get<1>(tblgenKey).drop_front()); } unsigned getLineCols(unsigned index) const { - return getTrailingObjects()[index - 1]; + return getTrailingObjects()[index - 1]; } unsigned getStartLine() const { return startLine; } diff --git a/mlir/lib/IR/TypeDetail.h b/mlir/lib/IR/TypeDetail.h index 19f3690c3d2dc..0e952d5c14c7e 100644 --- a/mlir/lib/IR/TypeDetail.h +++ b/mlir/lib/IR/TypeDetail.h @@ -102,7 +102,8 @@ struct FunctionTypeStorage : public TypeStorage { /// A type representing a collection of other types. struct TupleTypeStorage final : public TypeStorage, - public llvm::TrailingObjects { + private llvm::TrailingObjects { + friend llvm::TrailingObjects; using KeyTy = TypeRange; TupleTypeStorage(unsigned numTypes) : numElements(numTypes) {} @@ -116,7 +117,7 @@ struct TupleTypeStorage final auto *result = ::new (rawMem) TupleTypeStorage(key.size()); // Copy in the element types into the trailing storage. - llvm::uninitialized_copy(key, result->getTrailingObjects()); + llvm::uninitialized_copy(key, result->getTrailingObjects()); return result; } @@ -126,9 +127,7 @@ struct TupleTypeStorage final unsigned size() const { return numElements; } /// Return the held types. - ArrayRef getTypes() const { - return {getTrailingObjects(), size()}; - } + ArrayRef getTypes() const { return getTrailingObjects(size()); } KeyTy getAsKey() const { return getTypes(); }