diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 8d8b1ca938829..939b14b0351d6 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -279,7 +279,7 @@ class TemplateArgumentList final /// Produce this as an array ref. ArrayRef asArray() const { - return llvm::ArrayRef(data(), size()); + return getTrailingObjects(size()); } /// Retrieve the number of template arguments in this @@ -287,9 +287,7 @@ class TemplateArgumentList final unsigned size() const { return NumArguments; } /// Retrieve a pointer to the template argument list. - const TemplateArgument *data() const { - return getTrailingObjects(); - } + const TemplateArgument *data() const { return getTrailingObjects(); } }; void *allocateDefaultArgStorageChain(const ASTContext &C); @@ -505,12 +503,10 @@ class FunctionTemplateSpecializationInfo final TemplateArgumentsAsWritten(TemplateArgsAsWritten), PointOfInstantiation(POI) { if (MSInfo) - getTrailingObjects()[0] = MSInfo; + getTrailingObjects()[0] = MSInfo; } - size_t numTrailingObjects(OverloadToken) const { - return Function.getInt(); - } + size_t numTrailingObjects() const { return Function.getInt(); } public: friend TrailingObjects; @@ -597,9 +593,7 @@ class FunctionTemplateSpecializationInfo final /// function and the function template, and should always be /// TSK_ExplicitSpecialization whenever we have MemberSpecializationInfo. MemberSpecializationInfo *getMemberSpecializationInfo() const { - return numTrailingObjects(OverloadToken()) - ? getTrailingObjects()[0] - : nullptr; + return numTrailingObjects() ? getTrailingObjects()[0] : nullptr; } void Profile(llvm::FoldingSetNodeID &ID) { diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 9fc23d30b733f..41e50359962ee 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -7364,17 +7364,14 @@ class RecoveryExpr final : public Expr, ArrayRef SubExprs); static RecoveryExpr *CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs); - ArrayRef subExpressions() { - auto *B = getTrailingObjects(); - return llvm::ArrayRef(B, B + NumExprs); - } + ArrayRef subExpressions() { return getTrailingObjects(NumExprs); } ArrayRef subExpressions() const { return const_cast(this)->subExpressions(); } child_range children() { - Stmt **B = reinterpret_cast(getTrailingObjects()); + Stmt **B = reinterpret_cast(getTrailingObjects()); return child_range(B, B + NumExprs); } diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h index 67fbdfeb0702f..a778c7cc3dc98 100644 --- a/clang/include/clang/AST/OpenACCClause.h +++ b/clang/include/clang/AST/OpenACCClause.h @@ -307,7 +307,7 @@ class OpenACCDeviceTypeClause final } ArrayRef getArchitectures() const { - return getTrailingObjects(NumArchs); + return getTrailingObjects(NumArchs); } static OpenACCDeviceTypeClause * diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h index 6fd16bc0f03be..2fa8fa529741e 100644 --- a/clang/include/clang/AST/OpenMPClause.h +++ b/clang/include/clang/AST/OpenMPClause.h @@ -302,8 +302,7 @@ template class OMPVarListClause : public OMPClause { void setVarRefs(ArrayRef VL) { assert(VL.size() == NumVars && "Number of variables is not the same as the preallocated buffer"); - std::copy(VL.begin(), VL.end(), - static_cast(this)->template getTrailingObjects()); + llvm::copy(VL, getVarRefs().begin()); } public: @@ -388,9 +387,7 @@ template class OMPDirectiveListClause : public OMPClause { assert( DK.size() == NumKinds && "Number of directive kinds is not the same as the preallocated buffer"); - std::copy(DK.begin(), DK.end(), - static_cast(this) - ->template getTrailingObjects()); + std::copy(DK.begin(), DK.end(), getDirectiveKinds().begin()); } SourceLocation getLParenLoc() { return LParenLoc; } @@ -980,20 +977,14 @@ class OMPSizesClause final /// Returns the tile size expressions. MutableArrayRef getSizesRefs() { - return static_cast(this) - ->template getTrailingObjects(NumSizes); - } - ArrayRef getSizesRefs() const { - return static_cast(this) - ->template getTrailingObjects(NumSizes); + return getTrailingObjects(NumSizes); } + ArrayRef getSizesRefs() const { return getTrailingObjects(NumSizes); } /// Sets the tile size expressions. void setSizesRefs(ArrayRef VL) { assert(VL.size() == NumSizes); - std::copy(VL.begin(), VL.end(), - static_cast(this) - ->template getTrailingObjects()); + llvm::copy(VL, getSizesRefs().begin()); } child_range children() { @@ -1043,8 +1034,7 @@ class OMPPermutationClause final /// Sets the permutation index expressions. void setArgRefs(ArrayRef VL) { assert(VL.size() == NumLoops && "Expecting one expression per loop"); - llvm::copy(VL, static_cast(this) - ->template getTrailingObjects()); + llvm::copy(VL, getTrailingObjects()); } /// Build an empty clause. @@ -1083,14 +1073,8 @@ class OMPPermutationClause final /// Returns the permutation index expressions. ///@{ - MutableArrayRef getArgsRefs() { - return static_cast(this) - ->template getTrailingObjects(NumLoops); - } - ArrayRef getArgsRefs() const { - return static_cast(this) - ->template getTrailingObjects(NumLoops); - } + MutableArrayRef getArgsRefs() { return getTrailingObjects(NumLoops); } + ArrayRef getArgsRefs() const { return getTrailingObjects(NumLoops); } ///@} child_range children() { @@ -9239,9 +9223,7 @@ class OMPAffinityClause final SourceLocation(), N) {} /// Sets the affinity modifier for the clause, if any. - void setModifier(Expr *E) { - getTrailingObjects()[varlist_size()] = E; - } + void setModifier(Expr *E) { getTrailingObjects()[varlist_size()] = E; } /// Sets the location of ':' symbol. void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } @@ -9268,10 +9250,8 @@ class OMPAffinityClause final static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N); /// Gets affinity modifier. - Expr *getModifier() { return getTrailingObjects()[varlist_size()]; } - Expr *getModifier() const { - return getTrailingObjects()[varlist_size()]; - } + Expr *getModifier() { return getTrailingObjects()[varlist_size()]; } + Expr *getModifier() const { return getTrailingObjects()[varlist_size()]; } /// Gets the location of ':' symbol. SourceLocation getColonLoc() const { return ColonLoc; } diff --git a/clang/include/clang/AST/StmtOpenACC.h b/clang/include/clang/AST/StmtOpenACC.h index c8f8b968b1c80..9ad3d8e00d98a 100644 --- a/clang/include/clang/AST/StmtOpenACC.h +++ b/clang/include/clang/AST/StmtOpenACC.h @@ -736,7 +736,7 @@ class OpenACCUpdateConstruct final OpenACCDirectiveKind::Update, SourceLocation{}, SourceLocation{}, SourceLocation{}) { std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses); - setClauseList(getTrailingObjects(NumClauses)); + setClauseList(getTrailingObjects(NumClauses)); } OpenACCUpdateConstruct(SourceLocation Start, SourceLocation DirectiveLoc, diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3896cd914bf04..35a8b898d8e19 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -6052,9 +6052,7 @@ class PackIndexingType final ArrayRef Expansions); private: - const QualType *getExpansionsPtr() const { - return getTrailingObjects(); - } + const QualType *getExpansionsPtr() const { return getTrailingObjects(); } static TypeDependence computeDependence(QualType Pattern, Expr *IndexExpr, ArrayRef Expansions = {}); @@ -6494,7 +6492,7 @@ class HLSLInlineSpirvType final uint32_t getSize() const { return Size; } uint32_t getAlignment() const { return Alignment; } ArrayRef getOperands() const { - return getTrailingObjects(NumOperands); + return getTrailingObjects(NumOperands); } bool isSugared() const { return false; } diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 5c44353d8b987..96a5e2eeaa4d7 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -4452,7 +4452,7 @@ ExpectedDecl ASTNodeImporter::VisitFriendDecl(FriendDecl *D) { } SmallVector ToTPLists(D->NumTPLists); - auto **FromTPLists = D->getTrailingObjects(); + auto **FromTPLists = D->getTrailingObjects(); for (unsigned I = 0; I < D->NumTPLists; I++) { if (auto ListOrErr = import(FromTPLists[I])) ToTPLists[I] = *ListOrErr; diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 860968939b4ae..c4376aab480cd 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -5380,7 +5380,7 @@ PragmaCommentDecl *PragmaCommentDecl::Create(const ASTContext &C, new (C, DC, additionalSizeToAlloc(Arg.size() + 1)) PragmaCommentDecl(DC, CommentLoc, CommentKind); memcpy(PCD->getTrailingObjects(), Arg.data(), Arg.size()); - PCD->getTrailingObjects()[Arg.size()] = '\0'; + PCD->getTrailingObjects()[Arg.size()] = '\0'; return PCD; } diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 43b1c39d73798..2b66445fe253a 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -806,8 +806,7 @@ CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T, new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, RParenLoc, AngleBrackets); if (PathSize) - llvm::uninitialized_copy(*BasePath, - E->getTrailingObjects()); + llvm::uninitialized_copy(*BasePath, E->getTrailingObjects()); return E; } @@ -869,8 +868,7 @@ CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T, new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, RParenLoc, AngleBrackets); if (PathSize) - llvm::uninitialized_copy(*BasePath, - E->getTrailingObjects()); + llvm::uninitialized_copy(*BasePath, E->getTrailingObjects()); return E; } diff --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp index 0e5052b944162..f714974b94760 100644 --- a/clang/lib/AST/OpenMPClause.cpp +++ b/clang/lib/AST/OpenMPClause.cpp @@ -370,26 +370,26 @@ OMPOrderedClause *OMPOrderedClause::CreateEmpty(const ASTContext &C, void OMPOrderedClause::setLoopNumIterations(unsigned NumLoop, Expr *NumIterations) { assert(NumLoop < NumberOfLoops && "out of loops number."); - getTrailingObjects()[NumLoop] = NumIterations; + getTrailingObjects()[NumLoop] = NumIterations; } ArrayRef OMPOrderedClause::getLoopNumIterations() const { - return getTrailingObjects(NumberOfLoops); + return getTrailingObjects(NumberOfLoops); } void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) { assert(NumLoop < NumberOfLoops && "out of loops number."); - getTrailingObjects()[NumberOfLoops + NumLoop] = Counter; + getTrailingObjects()[NumberOfLoops + NumLoop] = Counter; } Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) { assert(NumLoop < NumberOfLoops && "out of loops number."); - return getTrailingObjects()[NumberOfLoops + NumLoop]; + return getTrailingObjects()[NumberOfLoops + NumLoop]; } const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const { assert(NumLoop < NumberOfLoops && "out of loops number."); - return getTrailingObjects()[NumberOfLoops + NumLoop]; + return getTrailingObjects()[NumberOfLoops + NumLoop]; } OMPUpdateClause *OMPUpdateClause::Create(const ASTContext &C, @@ -1678,7 +1678,7 @@ OMPInitClause *OMPInitClause::Create(const ASTContext &C, Expr *InteropVar, InteropInfo.IsTarget, InteropInfo.IsTargetSync, StartLoc, LParenLoc, VarLoc, EndLoc, InteropInfo.PreferTypes.size() + 1); Clause->setInteropVar(InteropVar); - llvm::copy(InteropInfo.PreferTypes, Clause->getTrailingObjects() + 1); + llvm::copy(InteropInfo.PreferTypes, Clause->getTrailingObjects() + 1); return Clause; } diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index a461dbde4093c..543f05e4ee7cc 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -3981,7 +3981,7 @@ CountAttributedType::CountAttributedType( CountAttributedTypeBits.NumCoupledDecls = CoupledDecls.size(); CountAttributedTypeBits.CountInBytes = CountInBytes; CountAttributedTypeBits.OrNull = OrNull; - auto *DeclSlot = getTrailingObjects(); + auto *DeclSlot = getTrailingObjects(); Decls = llvm::ArrayRef(DeclSlot, CoupledDecls.size()); for (unsigned i = 0; i != CoupledDecls.size(); ++i) DeclSlot[i] = CoupledDecls[i];