Skip to content

Commit c1d7943

Browse files
committed
Adjust code after changes to llvm::TrailingObjects API
See: - llvm/llvm-project#138970 - llvm/llvm-project#144930
1 parent 310eb74 commit c1d7943

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+244
-294
lines changed

include/swift/AST/Attr.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ class ObjCAttr final : public DeclAttribute,
10981098
unsigned length = 2;
10991099
if (auto name = getName())
11001100
length += name->getNumSelectorPieces();
1101-
return {getTrailingObjects<SourceLoc>(), length};
1101+
return getTrailingObjects(length);
11021102
}
11031103

11041104
/// Retrieve the trailing location information.
@@ -1107,7 +1107,7 @@ class ObjCAttr final : public DeclAttribute,
11071107
unsigned length = 2;
11081108
if (auto name = getName())
11091109
length += name->getNumSelectorPieces();
1110-
return {getTrailingObjects<SourceLoc>(), length};
1110+
return getTrailingObjects(length);
11111111
}
11121112

11131113
public:
@@ -1283,14 +1283,14 @@ class DynamicReplacementAttr final
12831283
MutableArrayRef<SourceLoc> getTrailingLocations() {
12841284
assert(Bits.DynamicReplacementAttr.HasTrailingLocationInfo);
12851285
unsigned length = 2;
1286-
return {getTrailingObjects<SourceLoc>(), length};
1286+
return getTrailingObjects(length);
12871287
}
12881288

12891289
/// Retrieve the trailing location information.
12901290
ArrayRef<SourceLoc> getTrailingLocations() const {
12911291
assert(Bits.DynamicReplacementAttr.HasTrailingLocationInfo);
12921292
unsigned length = 2; // lParens, rParens
1293-
return {getTrailingObjects<SourceLoc>(), length};
1293+
return getTrailingObjects(length);
12941294
}
12951295

12961296
public:
@@ -1480,8 +1480,7 @@ class SPIAccessControlAttr final : public DeclAttribute,
14801480
/// Note: A single SPI name per attribute is currently supported but this
14811481
/// may change with the syntax change.
14821482
ArrayRef<Identifier> getSPIGroups() const {
1483-
return { this->template getTrailingObjects<Identifier>(),
1484-
numSPIGroups };
1483+
return getTrailingObjects(numSPIGroups);
14851484
}
14861485

14871486
static bool classof(const DeclAttribute *DA) {
@@ -2059,11 +2058,11 @@ class StorageRestrictionsAttr final
20592058
unsigned getNumAccessesProperties() const { return NumAccesses; }
20602059

20612060
ArrayRef<Identifier> getInitializesNames() const {
2062-
return {getTrailingObjects<Identifier>(), NumInitializes};
2061+
return getTrailingObjects(NumInitializes);
20632062
}
20642063

20652064
ArrayRef<Identifier> getAccessesNames() const {
2066-
return {getTrailingObjects<Identifier>() + NumInitializes, NumAccesses};
2065+
return {getTrailingObjects() + NumInitializes, NumAccesses};
20672066
}
20682067

20692068
ArrayRef<VarDecl *> getInitializesProperties(AccessorDecl *attachedTo) const;
@@ -2560,10 +2559,10 @@ class DifferentiableAttr final
25602559
/// The parsed differentiability parameters, i.e. the list of parameters
25612560
/// specified in 'wrt:'.
25622561
ArrayRef<ParsedAutoDiffParameter> getParsedParameters() const {
2563-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2562+
return getTrailingObjects(NumParsedParameters);
25642563
}
25652564
MutableArrayRef<ParsedAutoDiffParameter> getParsedParameters() {
2566-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2565+
return getTrailingObjects(NumParsedParameters);
25672566
}
25682567
size_t numTrailingObjects(OverloadToken<ParsedAutoDiffParameter>) const {
25692568
return NumParsedParameters;
@@ -2745,10 +2744,10 @@ class DerivativeAttr final
27452744
/// The parsed differentiability parameters, i.e. the list of parameters
27462745
/// specified in 'wrt:'.
27472746
ArrayRef<ParsedAutoDiffParameter> getParsedParameters() const {
2748-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2747+
return getTrailingObjects(NumParsedParameters);
27492748
}
27502749
MutableArrayRef<ParsedAutoDiffParameter> getParsedParameters() {
2751-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2750+
return getTrailingObjects(NumParsedParameters);
27522751
}
27532752
size_t numTrailingObjects(OverloadToken<ParsedAutoDiffParameter>) const {
27542753
return NumParsedParameters;
@@ -2836,10 +2835,10 @@ class TransposeAttr final
28362835
/// The parsed linearity parameters, i.e. the list of parameters specified in
28372836
/// 'wrt:'.
28382837
ArrayRef<ParsedAutoDiffParameter> getParsedParameters() const {
2839-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2838+
return getTrailingObjects(NumParsedParameters);
28402839
}
28412840
MutableArrayRef<ParsedAutoDiffParameter> getParsedParameters() {
2842-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2841+
return getTrailingObjects(NumParsedParameters);
28432842
}
28442843
size_t numTrailingObjects(OverloadToken<ParsedAutoDiffParameter>) const {
28452844
return NumParsedParameters;
@@ -3490,8 +3489,8 @@ class AllowFeatureSuppressionAttr final
34903489
bool getInverted() const { return Bits.AllowFeatureSuppressionAttr.Inverted; }
34913490

34923491
ArrayRef<Identifier> getSuppressedFeatures() const {
3493-
return {getTrailingObjects<Identifier>(),
3494-
static_cast<size_t>(Bits.AllowFeatureSuppressionAttr.NumFeatures)};
3492+
return getTrailingObjects(
3493+
static_cast<size_t>(Bits.AllowFeatureSuppressionAttr.NumFeatures));
34953494
}
34963495

34973496
static bool classof(const DeclAttribute *DA) {

include/swift/AST/AvailabilityContextStorage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class AvailabilityContext::Storage final
8282
const ASTContext &ctx);
8383

8484
llvm::ArrayRef<DomainInfo> getDomainInfos() const {
85-
return llvm::ArrayRef(getTrailingObjects<DomainInfo>(), domainInfoCount);
85+
return getTrailingObjects(domainInfoCount);
8686
}
8787

8888
llvm::SmallVector<DomainInfo, 4> copyDomainInfos() const {

include/swift/AST/Decl.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,8 +1739,8 @@ class ImportDecl final : public Decl,
17391739
/// path will include 'Foo'. This return value is always owned by \c ImportDecl
17401740
/// (which is owned by the AST context), so it can be persisted.
17411741
ImportPath getImportPath() const {
1742-
return ImportPath({ getTrailingObjects<ImportPath::Element>(),
1743-
static_cast<size_t>(Bits.ImportDecl.NumPathElements) });
1742+
return ImportPath(getTrailingObjects(
1743+
static_cast<size_t>(Bits.ImportDecl.NumPathElements)));
17441744
}
17451745

17461746
/// Retrieves the import path, replacing any module aliases with real names.
@@ -2784,7 +2784,7 @@ class PatternBindingDecl final : public Decl,
27842784
private:
27852785
MutableArrayRef<PatternBindingEntry> getMutablePatternList() {
27862786
// Pattern entries are tail allocated.
2787-
return {getTrailingObjects<PatternBindingEntry>(), getNumPatternEntries()};
2787+
return getTrailingObjects(getNumPatternEntries());
27882788
}
27892789
};
27902790

@@ -3623,10 +3623,7 @@ class OpaqueTypeDecl final :
36233623
/// Retrieve the buffer containing the opaque return type
36243624
/// representations that correspond to the opaque generic parameters.
36253625
ArrayRef<TypeRepr *> getOpaqueReturnTypeReprs() const {
3626-
return {
3627-
getTrailingObjects<TypeRepr *>(),
3628-
getNumOpaqueReturnTypeReprs()
3629-
};
3626+
return getTrailingObjects(getNumOpaqueReturnTypeReprs());
36303627
}
36313628

36323629
/// Should the underlying type be visible to clients outside of the module?
@@ -3694,13 +3691,12 @@ class OpaqueTypeDecl final :
36943691
Substitutions(substitutions) {
36953692
assert(!availabilityContext.empty());
36963693
std::uninitialized_copy(availabilityContext.begin(),
3697-
availabilityContext.end(),
3698-
getTrailingObjects<AvailabilityCondition>());
3694+
availabilityContext.end(), getTrailingObjects());
36993695
}
37003696

37013697
public:
37023698
ArrayRef<AvailabilityCondition> getAvailability() const {
3703-
return {getTrailingObjects<AvailabilityCondition>(), NumAvailabilityConditions};
3699+
return getTrailingObjects(NumAvailabilityConditions);
37043700
}
37053701

37063702
SubstitutionMap getSubstitutions() const { return Substitutions; }
@@ -5884,7 +5880,7 @@ class AbstractStorageDecl : public ValueDecl {
58845880
inline AccessorDecl *getAccessor(AccessorKind kind) const;
58855881

58865882
ArrayRef<AccessorDecl *> getAllAccessors() const {
5887-
return { getTrailingObjects<AccessorDecl*>(), NumAccessors };
5883+
return getTrailingObjects(NumAccessors);
58885884
}
58895885

58905886
void addOpaqueAccessor(AccessorDecl *accessor);
@@ -5893,7 +5889,7 @@ class AbstractStorageDecl : public ValueDecl {
58935889

58945890
private:
58955891
MutableArrayRef<AccessorDecl *> getAccessorsBuffer() {
5896-
return { getTrailingObjects<AccessorDecl*>(), NumAccessors };
5892+
return getTrailingObjects(NumAccessors);
58975893
}
58985894

58995895
bool registerAccessor(AccessorDecl *accessor, AccessorIndex index);
@@ -8735,7 +8731,7 @@ class EnumCaseDecl final : public Decl,
87358731
{
87368732
Bits.EnumCaseDecl.NumElements = Elements.size();
87378733
std::uninitialized_copy(Elements.begin(), Elements.end(),
8738-
getTrailingObjects<EnumElementDecl *>());
8734+
getTrailingObjects());
87398735
}
87408736
SourceLoc getLocFromSource() const { return CaseLoc; }
87418737

@@ -8746,8 +8742,8 @@ class EnumCaseDecl final : public Decl,
87468742

87478743
/// Get the list of elements declared in this case.
87488744
ArrayRef<EnumElementDecl *> getElements() const {
8749-
return {getTrailingObjects<EnumElementDecl *>(),
8750-
static_cast<size_t>(Bits.EnumCaseDecl.NumElements)};
8745+
return getTrailingObjects(
8746+
static_cast<size_t>(Bits.EnumCaseDecl.NumElements));
87518747
}
87528748
SourceRange getSourceRange() const;
87538749

include/swift/AST/Expr.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,8 +3292,7 @@ class DestructureTupleExpr final : public ImplicitConversionExpr,
32923292
DstExpr(dstExpr) {
32933293
Bits.DestructureTupleExpr.NumElements = destructuredElements.size();
32943294
std::uninitialized_copy(destructuredElements.begin(),
3295-
destructuredElements.end(),
3296-
getTrailingObjects<OpaqueValueExpr *>());
3295+
destructuredElements.end(), getTrailingObjects());
32973296
}
32983297

32993298
public:
@@ -3305,8 +3304,8 @@ class DestructureTupleExpr final : public ImplicitConversionExpr,
33053304
Expr *srcExpr, Expr *dstExpr, Type ty);
33063305

33073306
ArrayRef<OpaqueValueExpr *> getDestructuredElements() const {
3308-
return {getTrailingObjects<OpaqueValueExpr *>(),
3309-
static_cast<size_t>(Bits.DestructureTupleExpr.NumElements)};
3307+
return getTrailingObjects(
3308+
static_cast<size_t>(Bits.DestructureTupleExpr.NumElements));
33103309
}
33113310

33123311
Expr *getResultExpr() const {
@@ -3726,7 +3725,7 @@ class UnresolvedSpecializeExpr final : public Expr,
37263725
SubExpr(SubExpr), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {
37273726
Bits.UnresolvedSpecializeExpr.NumUnresolvedParams = UnresolvedParams.size();
37283727
std::uninitialized_copy(UnresolvedParams.begin(), UnresolvedParams.end(),
3729-
getTrailingObjects<TypeRepr *>());
3728+
getTrailingObjects());
37303729
}
37313730

37323731
public:
@@ -3740,8 +3739,8 @@ class UnresolvedSpecializeExpr final : public Expr,
37403739
/// Retrieve the list of type parameters. These parameters have not yet
37413740
/// been bound to archetypes of the entity to be specialized.
37423741
ArrayRef<TypeRepr *> getUnresolvedParams() const {
3743-
return {getTrailingObjects<TypeRepr *>(),
3744-
static_cast<size_t>(Bits.UnresolvedSpecializeExpr.NumUnresolvedParams)};
3742+
return getTrailingObjects(
3743+
static_cast<size_t>(Bits.UnresolvedSpecializeExpr.NumUnresolvedParams));
37453744
}
37463745

37473746
SourceLoc getLoc() const { return LAngleLoc; }
@@ -3998,7 +3997,7 @@ class SequenceExpr final : public Expr,
39983997
Bits.SequenceExpr.NumElements = elements.size();
39993998
assert(Bits.SequenceExpr.NumElements > 0 && "zero-length sequence!");
40003999
std::uninitialized_copy(elements.begin(), elements.end(),
4001-
getTrailingObjects<Expr*>());
4000+
getTrailingObjects());
40024001
}
40034002

40044003
public:
@@ -4014,11 +4013,13 @@ class SequenceExpr final : public Expr,
40144013
unsigned getNumElements() const { return Bits.SequenceExpr.NumElements; }
40154014

40164015
MutableArrayRef<Expr*> getElements() {
4017-
return {getTrailingObjects<Expr*>(), static_cast<size_t>(Bits.SequenceExpr.NumElements)};
4016+
return getTrailingObjects(
4017+
static_cast<size_t>(Bits.SequenceExpr.NumElements));
40184018
}
40194019

40204020
ArrayRef<Expr*> getElements() const {
4021-
return {getTrailingObjects<Expr*>(), static_cast<size_t>(Bits.SequenceExpr.NumElements)};
4021+
return getTrailingObjects(
4022+
static_cast<size_t>(Bits.SequenceExpr.NumElements));
40224023
}
40234024

40244025
Expr *getElement(unsigned i) const {
@@ -4655,7 +4656,7 @@ class CaptureListExpr final : public Expr,
46554656
assert(closureBody);
46564657
Bits.CaptureListExpr.NumCaptures = captureList.size();
46574658
std::uninitialized_copy(captureList.begin(), captureList.end(),
4658-
getTrailingObjects<CaptureListEntry>());
4659+
getTrailingObjects());
46594660
}
46604661

46614662
public:
@@ -4664,8 +4665,8 @@ class CaptureListExpr final : public Expr,
46644665
AbstractClosureExpr *closureBody);
46654666

46664667
ArrayRef<CaptureListEntry> getCaptureList() {
4667-
return {getTrailingObjects<CaptureListEntry>(),
4668-
static_cast<size_t>(Bits.CaptureListExpr.NumCaptures)};
4668+
return getTrailingObjects(
4669+
static_cast<size_t>(Bits.CaptureListExpr.NumCaptures));
46694670
}
46704671
AbstractClosureExpr *getClosureBody() { return closureBody; }
46714672
const AbstractClosureExpr *getClosureBody() const { return closureBody; }
@@ -6605,7 +6606,7 @@ class TypeJoinExpr final : public Expr,
66056606
}
66066607

66076608
MutableArrayRef<Expr *> getMutableElements() {
6608-
return { getTrailingObjects<Expr *>(), getNumElements() };
6609+
return getTrailingObjects(getNumElements());
66096610
}
66106611

66116612
TypeJoinExpr(llvm::PointerUnion<DeclRefExpr *, TypeBase *> result,
@@ -6648,7 +6649,7 @@ class TypeJoinExpr final : public Expr,
66486649
}
66496650

66506651
ArrayRef<Expr *> getElements() const {
6651-
return { getTrailingObjects<Expr *>(), getNumElements() };
6652+
return getTrailingObjects(getNumElements());
66526653
}
66536654

66546655
Expr *getElement(unsigned i) const {

include/swift/AST/GenericParamList.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ class GenericParamList final :
277277
SourceLoc RAngleLoc);
278278

279279
MutableArrayRef<GenericTypeParamDecl *> getParams() {
280-
return {getTrailingObjects<GenericTypeParamDecl *>(), NumParams};
280+
return getTrailingObjects(NumParams);
281281
}
282282

283283
ArrayRef<GenericTypeParamDecl *> getParams() const {
284-
return {getTrailingObjects<GenericTypeParamDecl *>(), NumParams};
284+
return getTrailingObjects(NumParams);
285285
}
286286

287287
using iterator = GenericTypeParamDecl **;
@@ -387,12 +387,12 @@ class alignas(RequirementRepr) TrailingWhereClause final :
387387

388388
/// Retrieve the set of requirements.
389389
MutableArrayRef<RequirementRepr> getRequirements() {
390-
return {getTrailingObjects<RequirementRepr>(), NumRequirements};
390+
return getTrailingObjects(NumRequirements);
391391
}
392392

393393
/// Retrieve the set of requirements.
394394
ArrayRef<RequirementRepr> getRequirements() const {
395-
return {getTrailingObjects<RequirementRepr>(), NumRequirements};
395+
return getTrailingObjects(NumRequirements);
396396
}
397397

398398
/// Compute the source range containing this trailing where clause.

include/swift/AST/Identifier.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,10 @@ class DeclName {
518518
: BaseName(BaseName), NumArgs(NumArgs) { }
519519

520520
ArrayRef<Identifier> getArgumentNames() const {
521-
return {getTrailingObjects<Identifier>(), NumArgs};
521+
return getTrailingObjects(NumArgs);
522522
}
523523
MutableArrayRef<Identifier> getArgumentNames() {
524-
return {getTrailingObjects<Identifier>(), NumArgs};
524+
return getTrailingObjects(NumArgs);
525525
}
526526

527527
/// Uniquing for the ASTContext.

include/swift/AST/ImportCache.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,20 @@ class ImportSet final :
8787
}
8888

8989
ArrayRef<ImportedModule> getTopLevelImports() const {
90-
return {getTrailingObjects<ImportedModule>(),
91-
NumTopLevelImports};
90+
return getTrailingObjects(NumTopLevelImports);
9291
}
9392

9493
ArrayRef<ImportedModule> getTransitiveImports() const {
95-
return {getTrailingObjects<ImportedModule>() +
96-
NumTopLevelImports,
97-
NumTransitiveImports};
94+
return {getTrailingObjects() + NumTopLevelImports, NumTransitiveImports};
9895
}
9996

10097
ArrayRef<ImportedModule> getTransitiveSwiftOnlyImports() const {
101-
return {getTrailingObjects<ImportedModule>() +
102-
NumTopLevelImports + NumTransitiveImports,
98+
return {getTrailingObjects() + NumTopLevelImports + NumTransitiveImports,
10399
NumTransitiveSwiftOnlyImports};
104100
}
105101

106102
ArrayRef<ImportedModule> getAllImports() const {
107-
return {getTrailingObjects<ImportedModule>(),
108-
NumTopLevelImports + NumTransitiveImports};
103+
return getTrailingObjects(NumTopLevelImports + NumTransitiveImports);
109104
}
110105

111106
SWIFT_DEBUG_DUMP;

include/swift/AST/LifetimeDependence.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class LifetimeEntry final
170170
: startLoc(startLoc), endLoc(endLoc), numSources(sources.size()),
171171
targetDescriptor(targetDescriptor) {
172172
std::uninitialized_copy(sources.begin(), sources.end(),
173-
getTrailingObjects<LifetimeDescriptor>());
173+
getTrailingObjects());
174174
}
175175

176176
size_t numTrailingObjects(OverloadToken<LifetimeDescriptor>) const {
@@ -189,7 +189,7 @@ class LifetimeEntry final
189189
SourceLoc getEndLoc() const { return endLoc; }
190190

191191
ArrayRef<LifetimeDescriptor> getSources() const {
192-
return {getTrailingObjects<LifetimeDescriptor>(), numSources};
192+
return getTrailingObjects(numSources);
193193
}
194194

195195
std::optional<LifetimeDescriptor> getTargetDescriptor() const {

0 commit comments

Comments
 (0)