Skip to content

Commit 03a599c

Browse files
authored
Merge pull request #84606 from swiftlang/rebranch
Merge clang 21.x rebranch into main
2 parents 580f2e4 + 37a882d commit 03a599c

File tree

151 files changed

+2508
-880
lines changed

Some content is hidden

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

151 files changed

+2508
-880
lines changed

include/swift/ABI/ObjectFile.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
8383
}
8484
};
8585

86-
/// Responsible for providing the COFF reflection section identifiers
86+
/// Responsible for providing the COFF reflection section identifiers.
8787
class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
8888
public:
8989
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
@@ -101,5 +101,28 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
101101
return sectionName.starts_with(".sw5");
102102
}
103103
};
104+
105+
/// Responsible for providing the WebAssembly reflection section identifiers.
106+
/// WebAssembly binaries store all reflection metadata in the DATA
107+
/// section. There are symbols for each reflection section kind in the "name"
108+
/// section that point to the corresponding offset inside DATA.
109+
class SwiftObjectFileFormatWasm : public SwiftObjectFileFormat {
110+
public:
111+
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
112+
switch (section) {
113+
#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
114+
case KIND: \
115+
return ELF;
116+
#include "llvm/BinaryFormat/Swift.def"
117+
#undef HANDLE_SWIFT_SECTION
118+
}
119+
llvm_unreachable("Section not found.");
120+
}
121+
122+
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
123+
return sectionName.starts_with("swift5_");
124+
}
125+
};
126+
104127
} // namespace swift
105128
#endif // SWIFT_ABI_OBJECTFILE_H

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;
@@ -2562,10 +2561,10 @@ class DifferentiableAttr final
25622561
/// The parsed differentiability parameters, i.e. the list of parameters
25632562
/// specified in 'wrt:'.
25642563
ArrayRef<ParsedAutoDiffParameter> getParsedParameters() const {
2565-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2564+
return getTrailingObjects(NumParsedParameters);
25662565
}
25672566
MutableArrayRef<ParsedAutoDiffParameter> getParsedParameters() {
2568-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2567+
return getTrailingObjects(NumParsedParameters);
25692568
}
25702569
size_t numTrailingObjects(OverloadToken<ParsedAutoDiffParameter>) const {
25712570
return NumParsedParameters;
@@ -2747,10 +2746,10 @@ class DerivativeAttr final
27472746
/// The parsed differentiability parameters, i.e. the list of parameters
27482747
/// specified in 'wrt:'.
27492748
ArrayRef<ParsedAutoDiffParameter> getParsedParameters() const {
2750-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2749+
return getTrailingObjects(NumParsedParameters);
27512750
}
27522751
MutableArrayRef<ParsedAutoDiffParameter> getParsedParameters() {
2753-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2752+
return getTrailingObjects(NumParsedParameters);
27542753
}
27552754
size_t numTrailingObjects(OverloadToken<ParsedAutoDiffParameter>) const {
27562755
return NumParsedParameters;
@@ -2838,10 +2837,10 @@ class TransposeAttr final
28382837
/// The parsed linearity parameters, i.e. the list of parameters specified in
28392838
/// 'wrt:'.
28402839
ArrayRef<ParsedAutoDiffParameter> getParsedParameters() const {
2841-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2840+
return getTrailingObjects(NumParsedParameters);
28422841
}
28432842
MutableArrayRef<ParsedAutoDiffParameter> getParsedParameters() {
2844-
return {getTrailingObjects<ParsedAutoDiffParameter>(), NumParsedParameters};
2843+
return getTrailingObjects(NumParsedParameters);
28452844
}
28462845
size_t numTrailingObjects(OverloadToken<ParsedAutoDiffParameter>) const {
28472846
return NumParsedParameters;
@@ -3492,8 +3491,8 @@ class AllowFeatureSuppressionAttr final
34923491
bool getInverted() const { return Bits.AllowFeatureSuppressionAttr.Inverted; }
34933492

34943493
ArrayRef<Identifier> getSuppressedFeatures() const {
3495-
return {getTrailingObjects<Identifier>(),
3496-
static_cast<size_t>(Bits.AllowFeatureSuppressionAttr.NumFeatures)};
3494+
return getTrailingObjects(
3495+
static_cast<size_t>(Bits.AllowFeatureSuppressionAttr.NumFeatures));
34973496
}
34983497

34993498
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/Builtins.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ class BuiltinInfo {
121121

122122
/// The information identifying the llvm intrinsic - its id and types.
123123
class IntrinsicInfo {
124-
mutable llvm::AttributeList Attrs =
125-
llvm::DenseMapInfo<llvm::AttributeList>::getEmptyKey();
124+
mutable llvm::AttributeSet FnAttrs =
125+
llvm::DenseMapInfo<llvm::AttributeSet>::getEmptyKey();
126+
126127
public:
127128
llvm::Intrinsic::ID ID;
128129
SmallVector<Type, 4> Types;
129-
const llvm::AttributeList &getOrCreateAttributes(ASTContext &Ctx) const;
130+
const llvm::AttributeSet &getOrCreateFnAttributes(ASTContext &Ctx) const;
130131
};
131132

132133
/// Turn a string like "release" into the LLVM enum.

include/swift/AST/Decl.h

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

17841784
/// Retrieves the import path, replacing any module aliases with real names.
@@ -2824,7 +2824,7 @@ class PatternBindingDecl final : public Decl,
28242824
private:
28252825
MutableArrayRef<PatternBindingEntry> getMutablePatternList() {
28262826
// Pattern entries are tail allocated.
2827-
return {getTrailingObjects<PatternBindingEntry>(), getNumPatternEntries()};
2827+
return getTrailingObjects(getNumPatternEntries());
28282828
}
28292829
};
28302830

@@ -3680,10 +3680,7 @@ class OpaqueTypeDecl final :
36803680
/// Retrieve the buffer containing the opaque return type
36813681
/// representations that correspond to the opaque generic parameters.
36823682
ArrayRef<TypeRepr *> getOpaqueReturnTypeReprs() const {
3683-
return {
3684-
getTrailingObjects<TypeRepr *>(),
3685-
getNumOpaqueReturnTypeReprs()
3686-
};
3683+
return getTrailingObjects(getNumOpaqueReturnTypeReprs());
36873684
}
36883685

36893686
/// Should the underlying type be visible to clients outside of the module?
@@ -3749,13 +3746,12 @@ class OpaqueTypeDecl final :
37493746
Substitutions(substitutions) {
37503747
assert(!availabilityQueries.empty());
37513748
std::uninitialized_copy(availabilityQueries.begin(),
3752-
availabilityQueries.end(),
3753-
getTrailingObjects<AvailabilityQuery>());
3749+
availabilityQueries.end(), getTrailingObjects());
37543750
}
37553751

37563752
public:
37573753
ArrayRef<AvailabilityQuery> getAvailabilityQueries() const {
3758-
return {getTrailingObjects<AvailabilityQuery>(), NumAvailabilityQueries};
3754+
return getTrailingObjects(NumAvailabilityQueries);
37593755
}
37603756

37613757
SubstitutionMap getSubstitutions() const { return Substitutions; }
@@ -5949,7 +5945,7 @@ class AbstractStorageDecl : public ValueDecl {
59495945
inline AccessorDecl *getAccessor(AccessorKind kind) const;
59505946

59515947
ArrayRef<AccessorDecl *> getAllAccessors() const {
5952-
return { getTrailingObjects<AccessorDecl*>(), NumAccessors };
5948+
return getTrailingObjects(NumAccessors);
59535949
}
59545950

59555951
void addOpaqueAccessor(AccessorDecl *accessor);
@@ -5958,7 +5954,7 @@ class AbstractStorageDecl : public ValueDecl {
59585954

59595955
private:
59605956
MutableArrayRef<AccessorDecl *> getAccessorsBuffer() {
5961-
return { getTrailingObjects<AccessorDecl*>(), NumAccessors };
5957+
return getTrailingObjects(NumAccessors);
59625958
}
59635959

59645960
bool registerAccessor(AccessorDecl *accessor, AccessorIndex index);
@@ -8811,7 +8807,7 @@ class EnumCaseDecl final : public Decl,
88118807
{
88128808
Bits.EnumCaseDecl.NumElements = Elements.size();
88138809
std::uninitialized_copy(Elements.begin(), Elements.end(),
8814-
getTrailingObjects<EnumElementDecl *>());
8810+
getTrailingObjects());
88158811
}
88168812
SourceLoc getLocFromSource() const { return CaseLoc; }
88178813

@@ -8822,8 +8818,8 @@ class EnumCaseDecl final : public Decl,
88228818

88238819
/// Get the list of elements declared in this case.
88248820
ArrayRef<EnumElementDecl *> getElements() const {
8825-
return {getTrailingObjects<EnumElementDecl *>(),
8826-
static_cast<size_t>(Bits.EnumCaseDecl.NumElements)};
8821+
return getTrailingObjects(
8822+
static_cast<size_t>(Bits.EnumCaseDecl.NumElements));
88278823
}
88288824
SourceRange getSourceRange() const;
88298825

include/swift/AST/Expr.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
154154
Implicit : 1
155155
);
156156

157-
SWIFT_INLINE_BITFIELD_FULL(CollectionExpr, Expr, 64-NumExprBits,
157+
SWIFT_INLINE_BITFIELD_FULL(CollectionExpr, Expr, 64-NumberOfExprBits,
158158
/// True if the type of this collection expr was inferred by the collection
159159
/// fallback type, like [Any].
160160
IsTypeDefaulted : 1,
161161
/// Number of comma source locations.
162-
NumCommas : 32 - 1 - NumExprBits,
162+
NumCommas : 32 - 1 - NumberOfExprBits,
163163
/// Number of entries in the collection. If this is a DictionaryExpr,
164164
/// each entry is a Tuple with the key and value pair.
165165
NumSubExprs : 32
@@ -256,8 +256,8 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
256256
LitKind : 3
257257
);
258258

259-
SWIFT_INLINE_BITFIELD(AbstractClosureExpr, Expr, (16-NumExprBits)+16,
260-
: 16 - NumExprBits, // Align and leave room for subclasses
259+
SWIFT_INLINE_BITFIELD(AbstractClosureExpr, Expr, (16-NumberOfExprBits)+16,
260+
: 16 - NumberOfExprBits, // Align and leave room for subclasses
261261
Discriminator : 16
262262
);
263263

@@ -3293,8 +3293,7 @@ class DestructureTupleExpr final : public ImplicitConversionExpr,
32933293
DstExpr(dstExpr) {
32943294
Bits.DestructureTupleExpr.NumElements = destructuredElements.size();
32953295
std::uninitialized_copy(destructuredElements.begin(),
3296-
destructuredElements.end(),
3297-
getTrailingObjects<OpaqueValueExpr *>());
3296+
destructuredElements.end(), getTrailingObjects());
32983297
}
32993298

33003299
public:
@@ -3306,8 +3305,8 @@ class DestructureTupleExpr final : public ImplicitConversionExpr,
33063305
Expr *srcExpr, Expr *dstExpr, Type ty);
33073306

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

33133312
Expr *getResultExpr() const {
@@ -3712,7 +3711,7 @@ class UnresolvedSpecializeExpr final : public Expr,
37123711
SubExpr(SubExpr), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {
37133712
Bits.UnresolvedSpecializeExpr.NumUnresolvedParams = UnresolvedParams.size();
37143713
std::uninitialized_copy(UnresolvedParams.begin(), UnresolvedParams.end(),
3715-
getTrailingObjects<TypeRepr *>());
3714+
getTrailingObjects());
37163715
}
37173716

37183717
public:
@@ -3726,8 +3725,8 @@ class UnresolvedSpecializeExpr final : public Expr,
37263725
/// Retrieve the list of type parameters. These parameters have not yet
37273726
/// been bound to archetypes of the entity to be specialized.
37283727
ArrayRef<TypeRepr *> getUnresolvedParams() const {
3729-
return {getTrailingObjects<TypeRepr *>(),
3730-
static_cast<size_t>(Bits.UnresolvedSpecializeExpr.NumUnresolvedParams)};
3728+
return getTrailingObjects(
3729+
static_cast<size_t>(Bits.UnresolvedSpecializeExpr.NumUnresolvedParams));
37313730
}
37323731

37333732
SourceLoc getLoc() const { return LAngleLoc; }
@@ -3984,7 +3983,7 @@ class SequenceExpr final : public Expr,
39843983
Bits.SequenceExpr.NumElements = elements.size();
39853984
assert(Bits.SequenceExpr.NumElements > 0 && "zero-length sequence!");
39863985
std::uninitialized_copy(elements.begin(), elements.end(),
3987-
getTrailingObjects<Expr*>());
3986+
getTrailingObjects());
39883987
}
39893988

39903989
public:
@@ -4000,11 +3999,13 @@ class SequenceExpr final : public Expr,
40003999
unsigned getNumElements() const { return Bits.SequenceExpr.NumElements; }
40014000

40024001
MutableArrayRef<Expr*> getElements() {
4003-
return {getTrailingObjects<Expr*>(), static_cast<size_t>(Bits.SequenceExpr.NumElements)};
4002+
return getTrailingObjects(
4003+
static_cast<size_t>(Bits.SequenceExpr.NumElements));
40044004
}
40054005

40064006
ArrayRef<Expr*> getElements() const {
4007-
return {getTrailingObjects<Expr*>(), static_cast<size_t>(Bits.SequenceExpr.NumElements)};
4007+
return getTrailingObjects(
4008+
static_cast<size_t>(Bits.SequenceExpr.NumElements));
40084009
}
40094010

40104011
Expr *getElement(unsigned i) const {
@@ -4641,7 +4642,7 @@ class CaptureListExpr final : public Expr,
46414642
assert(closureBody);
46424643
Bits.CaptureListExpr.NumCaptures = captureList.size();
46434644
std::uninitialized_copy(captureList.begin(), captureList.end(),
4644-
getTrailingObjects<CaptureListEntry>());
4645+
getTrailingObjects());
46454646
}
46464647

46474648
public:
@@ -4650,8 +4651,8 @@ class CaptureListExpr final : public Expr,
46504651
AbstractClosureExpr *closureBody);
46514652

46524653
ArrayRef<CaptureListEntry> getCaptureList() {
4653-
return {getTrailingObjects<CaptureListEntry>(),
4654-
static_cast<size_t>(Bits.CaptureListExpr.NumCaptures)};
4654+
return getTrailingObjects(
4655+
static_cast<size_t>(Bits.CaptureListExpr.NumCaptures));
46554656
}
46564657
AbstractClosureExpr *getClosureBody() { return closureBody; }
46574658
const AbstractClosureExpr *getClosureBody() const { return closureBody; }
@@ -6591,7 +6592,7 @@ class TypeJoinExpr final : public Expr,
65916592
}
65926593

65936594
MutableArrayRef<Expr *> getMutableElements() {
6594-
return { getTrailingObjects<Expr *>(), getNumElements() };
6595+
return getTrailingObjects(getNumElements());
65956596
}
65966597

65976598
TypeJoinExpr(llvm::PointerUnion<DeclRefExpr *, TypeBase *> result,
@@ -6634,7 +6635,7 @@ class TypeJoinExpr final : public Expr,
66346635
}
66356636

66366637
ArrayRef<Expr *> getElements() const {
6637-
return { getTrailingObjects<Expr *>(), getNumElements() };
6638+
return getTrailingObjects(getNumElements());
66386639
}
66396640

66406641
Expr *getElement(unsigned i) const {

0 commit comments

Comments
 (0)