@@ -4115,8 +4115,7 @@ bool Parser::canParseCustomAttribute() {
41154115 return true ;
41164116}
41174117
4118- ParserResult<CustomAttr> Parser::parseCustomAttribute (
4119- SourceLoc atLoc, CustomAttributeInitializer *&initContext) {
4118+ ParserResult<CustomAttr> Parser::parseCustomAttribute (SourceLoc atLoc) {
41204119 assert (Tok.is (tok::identifier));
41214120
41224121 // Parse a custom attribute.
@@ -4133,14 +4132,14 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
41334132 // and global variables in libraries.
41344133 ParserStatus status;
41354134 ArgumentList *argList = nullptr ;
4135+ CustomAttributeInitializer *initContext = nullptr ;
41364136 if (Tok.isFollowingLParen () && isCustomAttributeArgument ()) {
41374137 // If we have no local context to parse the initial value into, create
41384138 // one for the attribute.
41394139 std::optional<ParseFunctionBody> initParser;
41404140 if (!CurDeclContext->isLocalContext ()) {
4141- if (!initContext)
4142- initContext = CustomAttributeInitializer::create (CurDeclContext);
4143-
4141+ assert (!initContext);
4142+ initContext = CustomAttributeInitializer::create (CurDeclContext);
41444143 initParser.emplace (*this , initContext);
41454144 }
41464145 if (getEndOfPreviousLoc () != Tok.getLoc ()) {
@@ -4191,7 +4190,6 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
41914190// /
41924191ParserStatus Parser::parseDeclAttribute (DeclAttributes &Attributes,
41934192 SourceLoc AtLoc, SourceLoc AtEndLoc,
4194- CustomAttributeInitializer *&initContext,
41954193 bool isFromClangAttribute) {
41964194 if (AtEndLoc != Tok.getLoc ()) {
41974195 diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4389,7 +4387,7 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
43894387 diagnose (Tok, diag::unknown_attribute, " unknown" );
43904388 } else {
43914389 // Change the context to create a custom attribute syntax.
4392- auto customAttr = parseCustomAttribute (AtLoc, initContext );
4390+ auto customAttr = parseCustomAttribute (AtLoc);
43934391 if (auto attr = customAttr.getPtrOrNull ())
43944392 Attributes.add (attr);
43954393
@@ -4406,10 +4404,9 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
44064404
44074405bool Parser::canParseTypeAttribute () {
44084406 TypeOrCustomAttr result; // ignored
4409- CustomAttributeInitializer *initContext = nullptr ;
44104407 return !parseTypeAttribute (result, /* atLoc=*/ SourceLoc (),
44114408 /* atEndLoc=*/ SourceLoc (),
4412- ParseTypeReason::Unspecified, initContext,
4409+ ParseTypeReason::Unspecified,
44134410 /* justChecking*/ true )
44144411 .isError ();
44154412}
@@ -4611,7 +4608,6 @@ bool Parser::parseUUIDString(UUID &uuid, Diag<> diagnostic, bool justChecking) {
46114608ParserStatus Parser::parseTypeAttribute (TypeOrCustomAttr &result,
46124609 SourceLoc AtLoc, SourceLoc AtEndLoc,
46134610 ParseTypeReason reason,
4614- CustomAttributeInitializer *&initContext,
46154611 bool justChecking) {
46164612 if (AtEndLoc != Tok.getLoc ()) {
46174613 diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4719,7 +4715,7 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
47194715 : makeParserError ();
47204716
47214717 // Parse as a custom attribute.
4722- auto customAttrResult = parseCustomAttribute (AtLoc, initContext );
4718+ auto customAttrResult = parseCustomAttribute (AtLoc);
47234719 if (customAttrResult.isParseErrorOrHasCompletion ())
47244720 return customAttrResult;
47254721
@@ -5086,34 +5082,23 @@ ParserResult<LifetimeEntry> Parser::parseLifetimeEntry(SourceLoc loc) {
50865082// / '@' attribute
50875083// / \endverbatim
50885084ParserStatus Parser::parseDeclAttributeList (
5089- DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs,
5090- CustomAttributeInitializer *&initContext) {
5085+ DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs) {
50915086 ParserStatus Status;
50925087 while (Tok.isAny (tok::at_sign, tok::pound_if)) {
50935088 if (Tok.is (tok::at_sign)) {
50945089 SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
50955090 SourceLoc AtLoc = consumeToken ();
5096- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5091+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
50975092 } else {
50985093 if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ())
50995094 break ;
51005095
5101- Status |= parseIfConfigAttributes (
5102- Attributes, ifConfigsAreDeclAttrs, initContext);
5096+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
51035097 }
51045098 }
51055099 return Status;
51065100}
51075101
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-
51175102// effectively parseDeclAttributeList but with selective modifier handling
51185103ParserStatus Parser::parseClosureDeclAttributeList (DeclAttributes &Attributes) {
51195104 auto parsingNonisolated = [this ] {
@@ -5124,23 +5109,21 @@ ParserStatus Parser::parseClosureDeclAttributeList(DeclAttributes &Attributes) {
51245109 if (Tok.isNot (tok::at_sign, tok::pound_if) && !parsingNonisolated ())
51255110 return makeParserSuccess ();
51265111
5127- CustomAttributeInitializer *initContext = nullptr ;
51285112 constexpr bool ifConfigsAreDeclAttrs = false ;
51295113 ParserStatus Status;
51305114 while (Tok.isAny (tok::at_sign, tok::pound_if) || parsingNonisolated ()) {
51315115 if (Tok.is (tok::at_sign)) {
51325116 SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
51335117 SourceLoc AtLoc = consumeToken ();
5134- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5118+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
51355119 } else if (parsingNonisolated ()) {
51365120 Status |=
51375121 parseNewDeclAttribute (Attributes, {}, DeclAttrKind::Nonisolated);
51385122 } else {
51395123 if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ()) {
51405124 break ;
51415125 }
5142- Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs,
5143- initContext);
5126+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
51445127 }
51455128 }
51465129 return Status;
@@ -5331,7 +5314,6 @@ ParserStatus Parser::parseDeclModifierList(DeclAttributes &Attributes,
53315314// / \endverbatim
53325315ParserStatus Parser::ParsedTypeAttributeList::slowParse (Parser &P) {
53335316 ParserStatus status;
5334- CustomAttributeInitializer *initContext = nullptr ;
53355317 auto &Tok = P.Tok ;
53365318 while (P.isParameterSpecifier ()) {
53375319 if (Tok.isContextualKeyword (" isolated" )) {
@@ -5431,7 +5413,7 @@ ParserStatus Parser::ParsedTypeAttributeList::slowParse(Parser &P) {
54315413 SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
54325414 SourceLoc AtLoc = P.consumeToken ();
54335415 status |=
5434- P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason, initContext );
5416+ P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason);
54355417 if (status.isError ())
54365418 return status;
54375419 if (result)
@@ -6116,9 +6098,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
61166098 DeclAttributes Attributes;
61176099 if (Tok.hasComment ())
61186100 Attributes.add (new (Context) RawDocCommentAttr (Tok.getCommentRange ()));
6119- CustomAttributeInitializer *attrInitContext = nullptr ;
61206101 ParserStatus AttrStatus = parseDeclAttributeList (
6121- Attributes, IfConfigsAreDeclAttrs, attrInitContext );
6102+ Attributes, IfConfigsAreDeclAttrs);
61226103
61236104 // Parse modifiers.
61246105 // Keep track of where and whether we see a contextual keyword on the decl.
@@ -8642,7 +8623,6 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
86428623 topLevelParser.emplace (*this , topLevelDecl);
86438624 if (initContext)
86448625 initParser.emplace (*this , initContext);
8645-
86468626
86478627 SourceLoc EqualLoc = consumeToken (tok::equal);
86488628 PBDEntries.back ().setEqualLoc (EqualLoc);
0 commit comments