@@ -4097,8 +4097,7 @@ bool Parser::canParseCustomAttribute() {
4097
4097
return true ;
4098
4098
}
4099
4099
4100
- ParserResult<CustomAttr> Parser::parseCustomAttribute (
4101
- SourceLoc atLoc, CustomAttributeInitializer *&initContext) {
4100
+ ParserResult<CustomAttr> Parser::parseCustomAttribute (SourceLoc atLoc) {
4102
4101
assert (Tok.is (tok::identifier));
4103
4102
4104
4103
// Parse a custom attribute.
@@ -4115,14 +4114,14 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
4115
4114
// and global variables in libraries.
4116
4115
ParserStatus status;
4117
4116
ArgumentList *argList = nullptr ;
4117
+ CustomAttributeInitializer *initContext = nullptr ;
4118
4118
if (Tok.isFollowingLParen () && isCustomAttributeArgument ()) {
4119
4119
// If we have no local context to parse the initial value into, create
4120
4120
// one for the attribute.
4121
4121
std::optional<ParseFunctionBody> initParser;
4122
4122
if (!CurDeclContext->isLocalContext ()) {
4123
- if (!initContext)
4124
- initContext = CustomAttributeInitializer::create (CurDeclContext);
4125
-
4123
+ assert (!initContext);
4124
+ initContext = CustomAttributeInitializer::create (CurDeclContext);
4126
4125
initParser.emplace (*this , initContext);
4127
4126
}
4128
4127
if (getEndOfPreviousLoc () != Tok.getLoc ()) {
@@ -4173,7 +4172,6 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
4173
4172
// /
4174
4173
ParserStatus Parser::parseDeclAttribute (DeclAttributes &Attributes,
4175
4174
SourceLoc AtLoc, SourceLoc AtEndLoc,
4176
- CustomAttributeInitializer *&initContext,
4177
4175
bool isFromClangAttribute) {
4178
4176
if (AtEndLoc != Tok.getLoc ()) {
4179
4177
diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4371,7 +4369,7 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
4371
4369
diagnose (Tok, diag::unknown_attribute, " unknown" );
4372
4370
} else {
4373
4371
// Change the context to create a custom attribute syntax.
4374
- auto customAttr = parseCustomAttribute (AtLoc, initContext );
4372
+ auto customAttr = parseCustomAttribute (AtLoc);
4375
4373
if (auto attr = customAttr.getPtrOrNull ())
4376
4374
Attributes.add (attr);
4377
4375
@@ -4388,10 +4386,9 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
4388
4386
4389
4387
bool Parser::canParseTypeAttribute () {
4390
4388
TypeOrCustomAttr result; // ignored
4391
- CustomAttributeInitializer *initContext = nullptr ;
4392
4389
return !parseTypeAttribute (result, /* atLoc=*/ SourceLoc (),
4393
4390
/* atEndLoc=*/ SourceLoc (),
4394
- ParseTypeReason::Unspecified, initContext,
4391
+ ParseTypeReason::Unspecified,
4395
4392
/* justChecking*/ true )
4396
4393
.isError ();
4397
4394
}
@@ -4593,7 +4590,6 @@ bool Parser::parseUUIDString(UUID &uuid, Diag<> diagnostic, bool justChecking) {
4593
4590
ParserStatus Parser::parseTypeAttribute (TypeOrCustomAttr &result,
4594
4591
SourceLoc AtLoc, SourceLoc AtEndLoc,
4595
4592
ParseTypeReason reason,
4596
- CustomAttributeInitializer *&initContext,
4597
4593
bool justChecking) {
4598
4594
if (AtEndLoc != Tok.getLoc ()) {
4599
4595
diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4701,7 +4697,7 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
4701
4697
: makeParserError ();
4702
4698
4703
4699
// Parse as a custom attribute.
4704
- auto customAttrResult = parseCustomAttribute (AtLoc, initContext );
4700
+ auto customAttrResult = parseCustomAttribute (AtLoc);
4705
4701
if (customAttrResult.isParseErrorOrHasCompletion ())
4706
4702
return customAttrResult;
4707
4703
@@ -5068,34 +5064,23 @@ ParserResult<LifetimeEntry> Parser::parseLifetimeEntry(SourceLoc loc) {
5068
5064
// / '@' attribute
5069
5065
// / \endverbatim
5070
5066
ParserStatus Parser::parseDeclAttributeList (
5071
- DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs,
5072
- CustomAttributeInitializer *&initContext) {
5067
+ DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs) {
5073
5068
ParserStatus Status;
5074
5069
while (Tok.isAny (tok::at_sign, tok::pound_if)) {
5075
5070
if (Tok.is (tok::at_sign)) {
5076
5071
SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
5077
5072
SourceLoc AtLoc = consumeToken ();
5078
- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5073
+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
5079
5074
} else {
5080
5075
if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ())
5081
5076
break ;
5082
5077
5083
- Status |= parseIfConfigAttributes (
5084
- Attributes, ifConfigsAreDeclAttrs, initContext);
5078
+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
5085
5079
}
5086
5080
}
5087
5081
return Status;
5088
5082
}
5089
5083
5090
- ParserStatus Parser::parseDeclAttributeList (
5091
- DeclAttributes &Attributes, bool IfConfigsAreDeclAttrs) {
5092
- if (Tok.isNot (tok::at_sign, tok::pound_if))
5093
- return makeParserSuccess ();
5094
-
5095
- CustomAttributeInitializer *initContext = nullptr ;
5096
- return parseDeclAttributeList (Attributes, IfConfigsAreDeclAttrs, initContext);
5097
- }
5098
-
5099
5084
// effectively parseDeclAttributeList but with selective modifier handling
5100
5085
ParserStatus Parser::parseClosureDeclAttributeList (DeclAttributes &Attributes) {
5101
5086
auto parsingNonisolated = [this ] {
@@ -5106,23 +5091,21 @@ ParserStatus Parser::parseClosureDeclAttributeList(DeclAttributes &Attributes) {
5106
5091
if (Tok.isNot (tok::at_sign, tok::pound_if) && !parsingNonisolated ())
5107
5092
return makeParserSuccess ();
5108
5093
5109
- CustomAttributeInitializer *initContext = nullptr ;
5110
5094
constexpr bool ifConfigsAreDeclAttrs = false ;
5111
5095
ParserStatus Status;
5112
5096
while (Tok.isAny (tok::at_sign, tok::pound_if) || parsingNonisolated ()) {
5113
5097
if (Tok.is (tok::at_sign)) {
5114
5098
SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
5115
5099
SourceLoc AtLoc = consumeToken ();
5116
- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5100
+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
5117
5101
} else if (parsingNonisolated ()) {
5118
5102
Status |=
5119
5103
parseNewDeclAttribute (Attributes, {}, DeclAttrKind::Nonisolated);
5120
5104
} else {
5121
5105
if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ()) {
5122
5106
break ;
5123
5107
}
5124
- Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs,
5125
- initContext);
5108
+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
5126
5109
}
5127
5110
}
5128
5111
return Status;
@@ -5313,7 +5296,6 @@ ParserStatus Parser::parseDeclModifierList(DeclAttributes &Attributes,
5313
5296
// / \endverbatim
5314
5297
ParserStatus Parser::ParsedTypeAttributeList::slowParse (Parser &P) {
5315
5298
ParserStatus status;
5316
- CustomAttributeInitializer *initContext = nullptr ;
5317
5299
auto &Tok = P.Tok ;
5318
5300
while (P.isParameterSpecifier ()) {
5319
5301
if (Tok.isContextualKeyword (" isolated" )) {
@@ -5413,7 +5395,7 @@ ParserStatus Parser::ParsedTypeAttributeList::slowParse(Parser &P) {
5413
5395
SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
5414
5396
SourceLoc AtLoc = P.consumeToken ();
5415
5397
status |=
5416
- P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason, initContext );
5398
+ P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason);
5417
5399
if (status.isError ())
5418
5400
return status;
5419
5401
if (result)
@@ -6098,9 +6080,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
6098
6080
DeclAttributes Attributes;
6099
6081
if (Tok.hasComment ())
6100
6082
Attributes.add (new (Context) RawDocCommentAttr (Tok.getCommentRange ()));
6101
- CustomAttributeInitializer *attrInitContext = nullptr ;
6102
6083
ParserStatus AttrStatus = parseDeclAttributeList (
6103
- Attributes, IfConfigsAreDeclAttrs, attrInitContext );
6084
+ Attributes, IfConfigsAreDeclAttrs);
6104
6085
6105
6086
// Parse modifiers.
6106
6087
// Keep track of where and whether we see a contextual keyword on the decl.
@@ -8624,7 +8605,6 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
8624
8605
topLevelParser.emplace (*this , topLevelDecl);
8625
8606
if (initContext)
8626
8607
initParser.emplace (*this , initContext);
8627
-
8628
8608
8629
8609
SourceLoc EqualLoc = consumeToken (tok::equal);
8630
8610
PBDEntries.back ().setEqualLoc (EqualLoc);
0 commit comments