@@ -4115,8 +4115,7 @@ bool Parser::canParseCustomAttribute() {
4115
4115
return true ;
4116
4116
}
4117
4117
4118
- ParserResult<CustomAttr> Parser::parseCustomAttribute (
4119
- SourceLoc atLoc, CustomAttributeInitializer *&initContext) {
4118
+ ParserResult<CustomAttr> Parser::parseCustomAttribute (SourceLoc atLoc) {
4120
4119
assert (Tok.is (tok::identifier));
4121
4120
4122
4121
// Parse a custom attribute.
@@ -4133,14 +4132,14 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
4133
4132
// and global variables in libraries.
4134
4133
ParserStatus status;
4135
4134
ArgumentList *argList = nullptr ;
4135
+ CustomAttributeInitializer *initContext = nullptr ;
4136
4136
if (Tok.isFollowingLParen () && isCustomAttributeArgument ()) {
4137
4137
// If we have no local context to parse the initial value into, create
4138
4138
// one for the attribute.
4139
4139
std::optional<ParseFunctionBody> initParser;
4140
4140
if (!CurDeclContext->isLocalContext ()) {
4141
- if (!initContext)
4142
- initContext = CustomAttributeInitializer::create (CurDeclContext);
4143
-
4141
+ assert (!initContext);
4142
+ initContext = CustomAttributeInitializer::create (CurDeclContext);
4144
4143
initParser.emplace (*this , initContext);
4145
4144
}
4146
4145
if (getEndOfPreviousLoc () != Tok.getLoc ()) {
@@ -4191,7 +4190,6 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
4191
4190
// /
4192
4191
ParserStatus Parser::parseDeclAttribute (DeclAttributes &Attributes,
4193
4192
SourceLoc AtLoc, SourceLoc AtEndLoc,
4194
- CustomAttributeInitializer *&initContext,
4195
4193
bool isFromClangAttribute) {
4196
4194
if (AtEndLoc != Tok.getLoc ()) {
4197
4195
diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4389,7 +4387,7 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
4389
4387
diagnose (Tok, diag::unknown_attribute, " unknown" );
4390
4388
} else {
4391
4389
// Change the context to create a custom attribute syntax.
4392
- auto customAttr = parseCustomAttribute (AtLoc, initContext );
4390
+ auto customAttr = parseCustomAttribute (AtLoc);
4393
4391
if (auto attr = customAttr.getPtrOrNull ())
4394
4392
Attributes.add (attr);
4395
4393
@@ -4406,10 +4404,9 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
4406
4404
4407
4405
bool Parser::canParseTypeAttribute () {
4408
4406
TypeOrCustomAttr result; // ignored
4409
- CustomAttributeInitializer *initContext = nullptr ;
4410
4407
return !parseTypeAttribute (result, /* atLoc=*/ SourceLoc (),
4411
4408
/* atEndLoc=*/ SourceLoc (),
4412
- ParseTypeReason::Unspecified, initContext,
4409
+ ParseTypeReason::Unspecified,
4413
4410
/* justChecking*/ true )
4414
4411
.isError ();
4415
4412
}
@@ -4611,7 +4608,6 @@ bool Parser::parseUUIDString(UUID &uuid, Diag<> diagnostic, bool justChecking) {
4611
4608
ParserStatus Parser::parseTypeAttribute (TypeOrCustomAttr &result,
4612
4609
SourceLoc AtLoc, SourceLoc AtEndLoc,
4613
4610
ParseTypeReason reason,
4614
- CustomAttributeInitializer *&initContext,
4615
4611
bool justChecking) {
4616
4612
if (AtEndLoc != Tok.getLoc ()) {
4617
4613
diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4719,7 +4715,7 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
4719
4715
: makeParserError ();
4720
4716
4721
4717
// Parse as a custom attribute.
4722
- auto customAttrResult = parseCustomAttribute (AtLoc, initContext );
4718
+ auto customAttrResult = parseCustomAttribute (AtLoc);
4723
4719
if (customAttrResult.isParseErrorOrHasCompletion ())
4724
4720
return customAttrResult;
4725
4721
@@ -5086,34 +5082,23 @@ ParserResult<LifetimeEntry> Parser::parseLifetimeEntry(SourceLoc loc) {
5086
5082
// / '@' attribute
5087
5083
// / \endverbatim
5088
5084
ParserStatus Parser::parseDeclAttributeList (
5089
- DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs,
5090
- CustomAttributeInitializer *&initContext) {
5085
+ DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs) {
5091
5086
ParserStatus Status;
5092
5087
while (Tok.isAny (tok::at_sign, tok::pound_if)) {
5093
5088
if (Tok.is (tok::at_sign)) {
5094
5089
SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
5095
5090
SourceLoc AtLoc = consumeToken ();
5096
- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5091
+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
5097
5092
} else {
5098
5093
if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ())
5099
5094
break ;
5100
5095
5101
- Status |= parseIfConfigAttributes (
5102
- Attributes, ifConfigsAreDeclAttrs, initContext);
5096
+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
5103
5097
}
5104
5098
}
5105
5099
return Status;
5106
5100
}
5107
5101
5108
- ParserStatus Parser::parseDeclAttributeList (
5109
- DeclAttributes &Attributes, bool IfConfigsAreDeclAttrs) {
5110
- if (Tok.isNot (tok::at_sign, tok::pound_if))
5111
- return makeParserSuccess ();
5112
-
5113
- CustomAttributeInitializer *initContext = nullptr ;
5114
- return parseDeclAttributeList (Attributes, IfConfigsAreDeclAttrs, initContext);
5115
- }
5116
-
5117
5102
// effectively parseDeclAttributeList but with selective modifier handling
5118
5103
ParserStatus Parser::parseClosureDeclAttributeList (DeclAttributes &Attributes) {
5119
5104
auto parsingNonisolated = [this ] {
@@ -5124,23 +5109,21 @@ ParserStatus Parser::parseClosureDeclAttributeList(DeclAttributes &Attributes) {
5124
5109
if (Tok.isNot (tok::at_sign, tok::pound_if) && !parsingNonisolated ())
5125
5110
return makeParserSuccess ();
5126
5111
5127
- CustomAttributeInitializer *initContext = nullptr ;
5128
5112
constexpr bool ifConfigsAreDeclAttrs = false ;
5129
5113
ParserStatus Status;
5130
5114
while (Tok.isAny (tok::at_sign, tok::pound_if) || parsingNonisolated ()) {
5131
5115
if (Tok.is (tok::at_sign)) {
5132
5116
SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
5133
5117
SourceLoc AtLoc = consumeToken ();
5134
- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5118
+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
5135
5119
} else if (parsingNonisolated ()) {
5136
5120
Status |=
5137
5121
parseNewDeclAttribute (Attributes, {}, DeclAttrKind::Nonisolated);
5138
5122
} else {
5139
5123
if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ()) {
5140
5124
break ;
5141
5125
}
5142
- Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs,
5143
- initContext);
5126
+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
5144
5127
}
5145
5128
}
5146
5129
return Status;
@@ -5331,7 +5314,6 @@ ParserStatus Parser::parseDeclModifierList(DeclAttributes &Attributes,
5331
5314
// / \endverbatim
5332
5315
ParserStatus Parser::ParsedTypeAttributeList::slowParse (Parser &P) {
5333
5316
ParserStatus status;
5334
- CustomAttributeInitializer *initContext = nullptr ;
5335
5317
auto &Tok = P.Tok ;
5336
5318
while (P.isParameterSpecifier ()) {
5337
5319
if (Tok.isContextualKeyword (" isolated" )) {
@@ -5431,7 +5413,7 @@ ParserStatus Parser::ParsedTypeAttributeList::slowParse(Parser &P) {
5431
5413
SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
5432
5414
SourceLoc AtLoc = P.consumeToken ();
5433
5415
status |=
5434
- P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason, initContext );
5416
+ P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason);
5435
5417
if (status.isError ())
5436
5418
return status;
5437
5419
if (result)
@@ -6116,9 +6098,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
6116
6098
DeclAttributes Attributes;
6117
6099
if (Tok.hasComment ())
6118
6100
Attributes.add (new (Context) RawDocCommentAttr (Tok.getCommentRange ()));
6119
- CustomAttributeInitializer *attrInitContext = nullptr ;
6120
6101
ParserStatus AttrStatus = parseDeclAttributeList (
6121
- Attributes, IfConfigsAreDeclAttrs, attrInitContext );
6102
+ Attributes, IfConfigsAreDeclAttrs);
6122
6103
6123
6104
// Parse modifiers.
6124
6105
// Keep track of where and whether we see a contextual keyword on the decl.
@@ -8642,7 +8623,6 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
8642
8623
topLevelParser.emplace (*this , topLevelDecl);
8643
8624
if (initContext)
8644
8625
initParser.emplace (*this , initContext);
8645
-
8646
8626
8647
8627
SourceLoc EqualLoc = consumeToken (tok::equal);
8648
8628
PBDEntries.back ().setEqualLoc (EqualLoc);
0 commit comments