Skip to content

Commit 201a5d0

Browse files
authored
Merge pull request #70326 from hamishknight/static-static
2 parents 3b38e15 + 5e7854f commit 201a5d0

File tree

11 files changed

+76
-124
lines changed

11 files changed

+76
-124
lines changed

include/swift/AST/Decl.h

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7754,8 +7754,7 @@ class FuncDecl : public AbstractFunctionDecl {
77547754
SourceLoc getFuncLoc() const { return FuncLoc; }
77557755

77567756
SourceLoc getStartLoc() const {
7757-
return StaticLoc.isValid() && !isa<AccessorDecl>(this)
7758-
? StaticLoc : FuncLoc;
7757+
return StaticLoc.isValid() ? StaticLoc : FuncLoc;
77597758
}
77607759
SourceRange getSourceRange() const;
77617760

@@ -7847,12 +7846,10 @@ class AccessorDecl final : public FuncDecl {
78477846

78487847
AccessorDecl(SourceLoc declLoc, SourceLoc accessorKeywordLoc,
78497848
AccessorKind accessorKind, AbstractStorageDecl *storage,
7850-
SourceLoc staticLoc, StaticSpellingKind staticSpelling,
78517849
bool async, SourceLoc asyncLoc, bool throws, SourceLoc throwsLoc,
7852-
TypeLoc thrownTy,
7853-
bool hasImplicitSelfDecl, DeclContext *parent)
7854-
: FuncDecl(DeclKind::Accessor, staticLoc, staticSpelling,
7855-
/*func loc*/ declLoc,
7850+
TypeLoc thrownTy, bool hasImplicitSelfDecl, DeclContext *parent)
7851+
: FuncDecl(DeclKind::Accessor, /*StaticLoc*/ SourceLoc(),
7852+
StaticSpellingKind::None, /*func loc*/ declLoc,
78567853
/*name*/ Identifier(), /*name loc*/ declLoc, async, asyncLoc,
78577854
throws, throwsLoc, thrownTy, hasImplicitSelfDecl,
78587855
/*genericParams*/ nullptr, parent),
@@ -7865,10 +7862,8 @@ class AccessorDecl final : public FuncDecl {
78657862
static AccessorDecl *
78667863
createImpl(ASTContext &ctx, SourceLoc declLoc, SourceLoc accessorKeywordLoc,
78677864
AccessorKind accessorKind, AbstractStorageDecl *storage,
7868-
SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool async,
7869-
SourceLoc asyncLoc, bool throws, SourceLoc throwsLoc,
7870-
TypeLoc thrownTy,
7871-
DeclContext *parent, ClangNode clangNode);
7865+
bool async, SourceLoc asyncLoc, bool throws, SourceLoc throwsLoc,
7866+
TypeLoc thrownTy, DeclContext *parent, ClangNode clangNode);
78727867

78737868
llvm::Optional<bool> getCachedIsTransparent() const {
78747869
if (Bits.AccessorDecl.IsTransparentComputed)
@@ -7879,22 +7874,17 @@ class AccessorDecl final : public FuncDecl {
78797874
friend class IsAccessorTransparentRequest;
78807875

78817876
public:
7882-
static AccessorDecl *createDeserialized(ASTContext &ctx,
7883-
AccessorKind accessorKind,
7884-
AbstractStorageDecl *storage,
7885-
StaticSpellingKind staticSpelling,
7886-
bool async, bool throws,
7887-
Type thrownType,
7888-
Type fnRetType, DeclContext *parent);
7877+
static AccessorDecl *
7878+
createDeserialized(ASTContext &ctx, AccessorKind accessorKind,
7879+
AbstractStorageDecl *storage, bool async, bool throws,
7880+
Type thrownType, Type fnRetType, DeclContext *parent);
78897881

78907882
static AccessorDecl *
78917883
create(ASTContext &ctx, SourceLoc declLoc, SourceLoc accessorKeywordLoc,
7892-
AccessorKind accessorKind, AbstractStorageDecl *storage,
7893-
SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool async,
7884+
AccessorKind accessorKind, AbstractStorageDecl *storage, bool async,
78947885
SourceLoc asyncLoc, bool throws, SourceLoc throwsLoc,
78957886
TypeLoc thrownType, ParameterList *parameterList, Type fnRetType,
7896-
DeclContext *parent,
7897-
ClangNode clangNode = ClangNode());
7887+
DeclContext *parent, ClangNode clangNode = ClangNode());
78987888

78997889
SourceLoc getAccessorKeywordLoc() const { return AccessorKeywordLoc; }
79007890

include/swift/Parse/Parser.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,12 +1272,11 @@ class Parser {
12721272
SourceLoc Loc, AccessorKind Kind, ParsedAccessors &accessors,
12731273
bool &hasEffectfulGet, ParameterList *Indices, bool &parsingLimitedSyntax,
12741274
DeclAttributes &Attributes, ParseDeclOptions Flags,
1275-
AbstractStorageDecl *storage, SourceLoc StaticLoc, ParserStatus &Status
1276-
);
1275+
AbstractStorageDecl *storage, ParserStatus &Status);
12771276

12781277
ParserStatus parseGetSet(ParseDeclOptions Flags, ParameterList *Indices,
12791278
TypeRepr *ResultType, ParsedAccessors &accessors,
1280-
AbstractStorageDecl *storage, SourceLoc StaticLoc);
1279+
AbstractStorageDecl *storage);
12811280
ParserResult<VarDecl> parseDeclVarGetSet(PatternBindingEntry &entry,
12821281
ParseDeclOptions Flags,
12831282
SourceLoc StaticLoc,

lib/AST/Decl.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10011,8 +10011,7 @@ bool FuncDecl::isStatic() const {
1001110011

1001210012
AccessorDecl *AccessorDecl::createImpl(
1001310013
ASTContext &ctx, SourceLoc declLoc, SourceLoc accessorKeywordLoc,
10014-
AccessorKind accessorKind, AbstractStorageDecl *storage,
10015-
SourceLoc staticLoc, StaticSpellingKind staticSpelling, bool async,
10014+
AccessorKind accessorKind, AbstractStorageDecl *storage, bool async,
1001610015
SourceLoc asyncLoc, bool throws, SourceLoc throwsLoc, TypeLoc thrownType,
1001710016
DeclContext *parent, ClangNode clangNode) {
1001810017
bool hasImplicitSelfDecl = parent->isTypeContext();
@@ -10021,10 +10020,9 @@ AccessorDecl *AccessorDecl::createImpl(
1002110020
: 0);
1002210021
void *buffer = allocateMemoryForDecl<AccessorDecl>(ctx, size,
1002310022
!clangNode.isNull());
10024-
auto D = ::new (buffer)
10025-
AccessorDecl(declLoc, accessorKeywordLoc, accessorKind, storage,
10026-
staticLoc, staticSpelling, async, asyncLoc, throws,
10027-
throwsLoc, thrownType, hasImplicitSelfDecl, parent);
10023+
auto D = ::new (buffer) AccessorDecl(
10024+
declLoc, accessorKeywordLoc, accessorKind, storage, async, asyncLoc,
10025+
throws, throwsLoc, thrownType, hasImplicitSelfDecl, parent);
1002810026
if (clangNode)
1002910027
D->setClangNode(clangNode);
1003010028
if (hasImplicitSelfDecl)
@@ -10033,31 +10031,32 @@ AccessorDecl *AccessorDecl::createImpl(
1003310031
return D;
1003410032
}
1003510033

10036-
AccessorDecl *AccessorDecl::createDeserialized(
10037-
ASTContext &ctx, AccessorKind accessorKind, AbstractStorageDecl *storage,
10038-
StaticSpellingKind staticSpelling, bool async, bool throws, Type thrownType,
10039-
Type fnRetType, DeclContext *parent) {
10034+
AccessorDecl *AccessorDecl::createDeserialized(ASTContext &ctx,
10035+
AccessorKind accessorKind,
10036+
AbstractStorageDecl *storage,
10037+
bool async, bool throws,
10038+
Type thrownType, Type fnRetType,
10039+
DeclContext *parent) {
1004010040
assert(fnRetType && "Deserialized result type must not be null");
1004110041
auto *const D = AccessorDecl::createImpl(
10042-
ctx, SourceLoc(), SourceLoc(), accessorKind, storage, SourceLoc(),
10043-
staticSpelling, async, SourceLoc(), throws, SourceLoc(),
10044-
TypeLoc::withoutLoc(thrownType), parent, ClangNode());
10042+
ctx, SourceLoc(), SourceLoc(), accessorKind, storage, async, SourceLoc(),
10043+
throws, SourceLoc(), TypeLoc::withoutLoc(thrownType), parent,
10044+
ClangNode());
1004510045
D->setResultInterfaceType(fnRetType);
1004610046
return D;
1004710047
}
1004810048

10049-
AccessorDecl *
10050-
AccessorDecl::create(ASTContext &ctx, SourceLoc declLoc,
10051-
SourceLoc accessorKeywordLoc, AccessorKind accessorKind,
10052-
AbstractStorageDecl *storage, SourceLoc staticLoc,
10053-
StaticSpellingKind staticSpelling, bool async,
10054-
SourceLoc asyncLoc, bool throws, SourceLoc throwsLoc,
10055-
TypeLoc thrownType, ParameterList *bodyParams, Type fnRetType,
10056-
DeclContext *parent, ClangNode clangNode) {
10049+
AccessorDecl *AccessorDecl::create(ASTContext &ctx, SourceLoc declLoc,
10050+
SourceLoc accessorKeywordLoc,
10051+
AccessorKind accessorKind,
10052+
AbstractStorageDecl *storage, bool async,
10053+
SourceLoc asyncLoc, bool throws,
10054+
SourceLoc throwsLoc, TypeLoc thrownType,
10055+
ParameterList *bodyParams, Type fnRetType,
10056+
DeclContext *parent, ClangNode clangNode) {
1005710057
auto *D = AccessorDecl::createImpl(
10058-
ctx, declLoc, accessorKeywordLoc, accessorKind, storage, staticLoc,
10059-
staticSpelling, async, asyncLoc, throws, throwsLoc, thrownType, parent,
10060-
clangNode);
10058+
ctx, declLoc, accessorKeywordLoc, accessorKind, storage, async, asyncLoc,
10059+
throws, throwsLoc, thrownType, parent, clangNode);
1006110060
D->setParameters(bodyParams);
1006210061
D->setResultInterfaceType(fnRetType);
1006310062
return D;

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5491,8 +5491,6 @@ makeBaseClassMemberAccessors(DeclContext *declContext,
54915491
/*FuncLoc=*/SourceLoc(),
54925492
/*AccessorKeywordLoc=*/SourceLoc(),
54935493
useAddress ? AccessorKind::Address : AccessorKind::Get, computedVar,
5494-
/*StaticLoc=*/SourceLoc(),
5495-
StaticSpellingKind::None, // TODO: we should handle static vars.
54965494
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
54975495
/*Throws=*/false,
54985496
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(), bodyParams,
@@ -5528,8 +5526,6 @@ makeBaseClassMemberAccessors(DeclContext *declContext,
55285526
/*AccessorKeywordLoc=*/SourceLoc(),
55295527
useAddress ? AccessorKind::MutableAddress : AccessorKind::Set,
55305528
computedVar,
5531-
/*StaticLoc=*/SourceLoc(),
5532-
StaticSpellingKind::None, // TODO: we should handle static vars.
55335529
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
55345530
/*Throws=*/false,
55355531
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(), setterBodyParams,

lib/ClangImporter/ImportDecl.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ createFuncOrAccessor(ClangImporter::Implementation &impl, SourceLoc funcLoc,
107107
decl = AccessorDecl::create(
108108
impl.SwiftContext, funcLoc,
109109
/*accessorKeywordLoc*/ SourceLoc(), accessorInfo->Kind,
110-
accessorInfo->Storage,
111-
/*StaticLoc*/ SourceLoc(), StaticSpellingKind::None, async,
112-
/*AsyncLoc=*/SourceLoc(), throws, /*ThrowsLoc=*/SourceLoc(),
113-
/*ThrownType=*/TypeLoc(), bodyParams, resultTy, dc, clangNode);
110+
accessorInfo->Storage, async, /*AsyncLoc=*/SourceLoc(),
111+
throws, /*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
112+
bodyParams, resultTy, dc, clangNode);
114113
} else {
115114
decl = FuncDecl::createImported(impl.SwiftContext, funcLoc, name, nameLoc,
116115
async, throws, /*thrownType=*/Type(),
@@ -632,11 +631,9 @@ static bool addErrorDomain(NominalTypeDecl *swiftDecl,
632631
/*FuncLoc=*/SourceLoc(),
633632
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Get,
634633
errorDomainPropertyDecl,
635-
/*StaticLoc=*/SourceLoc(), StaticSpellingKind::None,
636634
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
637-
/*Throws=*/false,
638-
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
639-
params, stringTy, swiftDecl);
635+
/*Throws=*/false, /*ThrowsLoc=*/SourceLoc(),
636+
/*ThrownType=*/TypeLoc(), params, stringTy, swiftDecl);
640637
getterDecl->setIsObjC(false);
641638
getterDecl->setIsDynamic(false);
642639
getterDecl->setIsTransparent(false);

lib/ClangImporter/SwiftDeclSynthesizer.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ static AccessorDecl *makeFieldGetterDecl(ClangImporter::Implementation &Impl,
8989
C,
9090
/*declLoc=*/importedFieldDecl->getLoc(),
9191
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Get, importedFieldDecl,
92-
/*StaticLoc=*/SourceLoc(), StaticSpellingKind::None,
9392
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
9493
/*Throws=*/false,
9594
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -119,7 +118,6 @@ static AccessorDecl *makeFieldSetterDecl(ClangImporter::Implementation &Impl,
119118
C,
120119
/*declLoc=*/SourceLoc(),
121120
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Set, importedFieldDecl,
122-
/*StaticLoc=*/SourceLoc(), StaticSpellingKind::None,
123121
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
124122
/*Throws=*/false,
125123
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -406,7 +404,6 @@ ValueDecl *SwiftDeclSynthesizer::createConstant(
406404
C,
407405
/*declLoc=*/SourceLoc(),
408406
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Get, var,
409-
/*StaticLoc=*/SourceLoc(), StaticSpellingKind::None,
410407
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
411408
/*Throws=*/false,
412409
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -1338,7 +1335,6 @@ void SwiftDeclSynthesizer::makeEnumRawValueGetter(EnumDecl *enumDecl,
13381335
C,
13391336
/*declLoc=*/SourceLoc(),
13401337
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Get, rawValueDecl,
1341-
/*StaticLoc=*/SourceLoc(), StaticSpellingKind::None,
13421338
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
13431339
/*Throws=*/false,
13441340
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -1403,7 +1399,6 @@ AccessorDecl *SwiftDeclSynthesizer::makeStructRawValueGetter(
14031399
C,
14041400
/*declLoc=*/SourceLoc(),
14051401
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Get, computedVar,
1406-
/*StaticLoc=*/SourceLoc(), StaticSpellingKind::None,
14071402
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
14081403
/*Throws=*/false,
14091404
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -1433,7 +1428,6 @@ AccessorDecl *SwiftDeclSynthesizer::buildSubscriptGetterDecl(
14331428
C,
14341429
/*declLoc=*/loc,
14351430
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Get, subscript,
1436-
/*StaticLoc=*/SourceLoc(), subscript->getStaticSpelling(),
14371431
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
14381432
/*Throws=*/false,
14391433
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -1477,7 +1471,6 @@ AccessorDecl *SwiftDeclSynthesizer::buildSubscriptSetterDecl(
14771471
C,
14781472
/*declLoc=*/setter->getLoc(),
14791473
/*AccessorKeywordLoc=*/SourceLoc(), AccessorKind::Set, subscript,
1480-
/*StaticLoc=*/SourceLoc(), subscript->getStaticSpelling(),
14811474
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
14821475
/*Throws=*/false,
14831476
/*ThrowsLoc=*/SourceLoc(), /*ThrownType=*/TypeLoc(),
@@ -1686,12 +1679,12 @@ SubscriptDecl *SwiftDeclSynthesizer::makeSubscript(FuncDecl *getter,
16861679
elementTy, dc, getterImpl->getClangNode());
16871680
subscript->setAccess(AccessLevel::Public);
16881681

1689-
AccessorDecl *getterDecl = AccessorDecl::create(
1690-
ctx, getterImpl->getLoc(), getterImpl->getLoc(), AccessorKind::Get,
1691-
subscript, SourceLoc(), subscript->getStaticSpelling(),
1692-
/*async*/ false, SourceLoc(),
1693-
/*throws*/ false, SourceLoc(), /*ThrownType=*/TypeLoc(),
1694-
bodyParams, elementTy, dc);
1682+
AccessorDecl *getterDecl =
1683+
AccessorDecl::create(ctx, getterImpl->getLoc(), getterImpl->getLoc(),
1684+
AccessorKind::Get, subscript,
1685+
/*async*/ false, SourceLoc(),
1686+
/*throws*/ false, SourceLoc(),
1687+
/*ThrownType=*/TypeLoc(), bodyParams, elementTy, dc);
16951688
getterDecl->setAccess(AccessLevel::Public);
16961689
getterDecl->setImplicit();
16971690
getterDecl->setIsDynamic(false);
@@ -1716,7 +1709,7 @@ SubscriptDecl *SwiftDeclSynthesizer::makeSubscript(FuncDecl *getter,
17161709

17171710
setterDecl = AccessorDecl::create(
17181711
ctx, setterImpl->getLoc(), setterImpl->getLoc(), AccessorKind::Set,
1719-
subscript, SourceLoc(), subscript->getStaticSpelling(),
1712+
subscript,
17201713
/*async*/ false, SourceLoc(),
17211714
/*throws*/ false, SourceLoc(), /*ThrownType=*/TypeLoc(),
17221715
setterParamList, TupleType::getEmpty(ctx), dc);
@@ -1774,7 +1767,6 @@ SwiftDeclSynthesizer::makeDereferencedPointeeProperty(FuncDecl *getter,
17741767
AccessorDecl *getterDecl = AccessorDecl::create(
17751768
ctx, getterImpl->getLoc(), getterImpl->getLoc(),
17761769
useAddress ? AccessorKind::Address : AccessorKind::Get, result,
1777-
SourceLoc(), StaticSpellingKind::None,
17781770
/*async*/ false, SourceLoc(),
17791771
/*throws*/ false, SourceLoc(), /*ThrownType=*/TypeLoc(),
17801772
ParameterList::createEmpty(ctx),
@@ -1812,7 +1804,6 @@ SwiftDeclSynthesizer::makeDereferencedPointeeProperty(FuncDecl *getter,
18121804
setterDecl = AccessorDecl::create(
18131805
ctx, setterImpl->getLoc(), setterImpl->getLoc(),
18141806
useAddress ? AccessorKind::MutableAddress : AccessorKind::Set, result,
1815-
SourceLoc(), StaticSpellingKind::None,
18161807
/*async*/ false, SourceLoc(),
18171808
/*throws*/ false, SourceLoc(), /*ThrownType=*/TypeLoc(),
18181809
setterParamList,
@@ -2117,7 +2108,6 @@ SwiftDeclSynthesizer::makeComputedPropertyFromCXXMethods(FuncDecl *getter,
21172108

21182109
AccessorDecl *getterDecl = AccessorDecl::create(
21192110
ctx, getter->getLoc(), getter->getLoc(), AccessorKind::Get, result,
2120-
SourceLoc(), StaticSpellingKind::None,
21212111
/*async*/ false, SourceLoc(),
21222112
/*throws*/ false, SourceLoc(), /*ThrownType=*/TypeLoc(),
21232113
ParameterList::createEmpty(ctx),
@@ -2144,7 +2134,6 @@ SwiftDeclSynthesizer::makeComputedPropertyFromCXXMethods(FuncDecl *getter,
21442134

21452135
setterDecl = AccessorDecl::create(
21462136
ctx, setter->getLoc(), setter->getLoc(), AccessorKind::Set, result,
2147-
SourceLoc(), StaticSpellingKind::None,
21482137
/*async*/ false, SourceLoc(),
21492138
/*throws*/ false, SourceLoc(), /*thrownType*/ TypeLoc(),
21502139
setterParamList, setter->getResultInterfaceType(), dc);

0 commit comments

Comments
 (0)