@@ -4097,8 +4097,7 @@ bool Parser::canParseCustomAttribute() {
40974097 return true ;
40984098}
40994099
4100- ParserResult<CustomAttr> Parser::parseCustomAttribute (
4101- SourceLoc atLoc, CustomAttributeInitializer *&initContext) {
4100+ ParserResult<CustomAttr> Parser::parseCustomAttribute (SourceLoc atLoc) {
41024101 assert (Tok.is (tok::identifier));
41034102
41044103 // Parse a custom attribute.
@@ -4115,14 +4114,14 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
41154114 // and global variables in libraries.
41164115 ParserStatus status;
41174116 ArgumentList *argList = nullptr ;
4117+ CustomAttributeInitializer *initContext = nullptr ;
41184118 if (Tok.isFollowingLParen () && isCustomAttributeArgument ()) {
41194119 // If we have no local context to parse the initial value into, create
41204120 // one for the attribute.
41214121 std::optional<ParseFunctionBody> initParser;
41224122 if (!CurDeclContext->isLocalContext ()) {
4123- if (!initContext)
4124- initContext = CustomAttributeInitializer::create (CurDeclContext);
4125-
4123+ assert (!initContext);
4124+ initContext = CustomAttributeInitializer::create (CurDeclContext);
41264125 initParser.emplace (*this , initContext);
41274126 }
41284127 if (getEndOfPreviousLoc () != Tok.getLoc ()) {
@@ -4173,7 +4172,6 @@ ParserResult<CustomAttr> Parser::parseCustomAttribute(
41734172// /
41744173ParserStatus Parser::parseDeclAttribute (DeclAttributes &Attributes,
41754174 SourceLoc AtLoc, SourceLoc AtEndLoc,
4176- CustomAttributeInitializer *&initContext,
41774175 bool isFromClangAttribute) {
41784176 if (AtEndLoc != Tok.getLoc ()) {
41794177 diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4371,7 +4369,7 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
43714369 diagnose (Tok, diag::unknown_attribute, " unknown" );
43724370 } else {
43734371 // Change the context to create a custom attribute syntax.
4374- auto customAttr = parseCustomAttribute (AtLoc, initContext );
4372+ auto customAttr = parseCustomAttribute (AtLoc);
43754373 if (auto attr = customAttr.getPtrOrNull ())
43764374 Attributes.add (attr);
43774375
@@ -4388,10 +4386,9 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes,
43884386
43894387bool Parser::canParseTypeAttribute () {
43904388 TypeOrCustomAttr result; // ignored
4391- CustomAttributeInitializer *initContext = nullptr ;
43924389 return !parseTypeAttribute (result, /* atLoc=*/ SourceLoc (),
43934390 /* atEndLoc=*/ SourceLoc (),
4394- ParseTypeReason::Unspecified, initContext,
4391+ ParseTypeReason::Unspecified,
43954392 /* justChecking*/ true )
43964393 .isError ();
43974394}
@@ -4593,7 +4590,6 @@ bool Parser::parseUUIDString(UUID &uuid, Diag<> diagnostic, bool justChecking) {
45934590ParserStatus Parser::parseTypeAttribute (TypeOrCustomAttr &result,
45944591 SourceLoc AtLoc, SourceLoc AtEndLoc,
45954592 ParseTypeReason reason,
4596- CustomAttributeInitializer *&initContext,
45974593 bool justChecking) {
45984594 if (AtEndLoc != Tok.getLoc ()) {
45994595 diagnose (AtEndLoc, diag::attr_extra_whitespace_after_at)
@@ -4701,7 +4697,7 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
47014697 : makeParserError ();
47024698
47034699 // Parse as a custom attribute.
4704- auto customAttrResult = parseCustomAttribute (AtLoc, initContext );
4700+ auto customAttrResult = parseCustomAttribute (AtLoc);
47054701 if (customAttrResult.isParseErrorOrHasCompletion ())
47064702 return customAttrResult;
47074703
@@ -5068,34 +5064,23 @@ ParserResult<LifetimeEntry> Parser::parseLifetimeEntry(SourceLoc loc) {
50685064// / '@' attribute
50695065// / \endverbatim
50705066ParserStatus Parser::parseDeclAttributeList (
5071- DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs,
5072- CustomAttributeInitializer *&initContext) {
5067+ DeclAttributes &Attributes, bool ifConfigsAreDeclAttrs) {
50735068 ParserStatus Status;
50745069 while (Tok.isAny (tok::at_sign, tok::pound_if)) {
50755070 if (Tok.is (tok::at_sign)) {
50765071 SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
50775072 SourceLoc AtLoc = consumeToken ();
5078- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5073+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
50795074 } else {
50805075 if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ())
50815076 break ;
50825077
5083- Status |= parseIfConfigAttributes (
5084- Attributes, ifConfigsAreDeclAttrs, initContext);
5078+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
50855079 }
50865080 }
50875081 return Status;
50885082}
50895083
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-
50995084// effectively parseDeclAttributeList but with selective modifier handling
51005085ParserStatus Parser::parseClosureDeclAttributeList (DeclAttributes &Attributes) {
51015086 auto parsingNonisolated = [this ] {
@@ -5106,23 +5091,21 @@ ParserStatus Parser::parseClosureDeclAttributeList(DeclAttributes &Attributes) {
51065091 if (Tok.isNot (tok::at_sign, tok::pound_if) && !parsingNonisolated ())
51075092 return makeParserSuccess ();
51085093
5109- CustomAttributeInitializer *initContext = nullptr ;
51105094 constexpr bool ifConfigsAreDeclAttrs = false ;
51115095 ParserStatus Status;
51125096 while (Tok.isAny (tok::at_sign, tok::pound_if) || parsingNonisolated ()) {
51135097 if (Tok.is (tok::at_sign)) {
51145098 SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
51155099 SourceLoc AtLoc = consumeToken ();
5116- Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc, initContext );
5100+ Status |= parseDeclAttribute (Attributes, AtLoc, AtEndLoc);
51175101 } else if (parsingNonisolated ()) {
51185102 Status |=
51195103 parseNewDeclAttribute (Attributes, {}, DeclAttrKind::Nonisolated);
51205104 } else {
51215105 if (!ifConfigsAreDeclAttrs && !ifConfigContainsOnlyAttributes ()) {
51225106 break ;
51235107 }
5124- Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs,
5125- initContext);
5108+ Status |= parseIfConfigAttributes (Attributes, ifConfigsAreDeclAttrs);
51265109 }
51275110 }
51285111 return Status;
@@ -5313,7 +5296,6 @@ ParserStatus Parser::parseDeclModifierList(DeclAttributes &Attributes,
53135296// / \endverbatim
53145297ParserStatus Parser::ParsedTypeAttributeList::slowParse (Parser &P) {
53155298 ParserStatus status;
5316- CustomAttributeInitializer *initContext = nullptr ;
53175299 auto &Tok = P.Tok ;
53185300 while (P.isParameterSpecifier ()) {
53195301 if (Tok.isContextualKeyword (" isolated" )) {
@@ -5413,7 +5395,7 @@ ParserStatus Parser::ParsedTypeAttributeList::slowParse(Parser &P) {
54135395 SourceLoc AtEndLoc = Tok.getRange ().getEnd ();
54145396 SourceLoc AtLoc = P.consumeToken ();
54155397 status |=
5416- P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason, initContext );
5398+ P.parseTypeAttribute (result, AtLoc, AtEndLoc, ParseReason);
54175399 if (status.isError ())
54185400 return status;
54195401 if (result)
@@ -6098,9 +6080,8 @@ ParserStatus Parser::parseDecl(bool IsAtStartOfLineOrPreviousHadSemi,
60986080 DeclAttributes Attributes;
60996081 if (Tok.hasComment ())
61006082 Attributes.add (new (Context) RawDocCommentAttr (Tok.getCommentRange ()));
6101- CustomAttributeInitializer *attrInitContext = nullptr ;
61026083 ParserStatus AttrStatus = parseDeclAttributeList (
6103- Attributes, IfConfigsAreDeclAttrs, attrInitContext );
6084+ Attributes, IfConfigsAreDeclAttrs);
61046085
61056086 // Parse modifiers.
61066087 // Keep track of where and whether we see a contextual keyword on the decl.
@@ -8624,7 +8605,6 @@ Parser::parseDeclVar(ParseDeclOptions Flags,
86248605 topLevelParser.emplace (*this , topLevelDecl);
86258606 if (initContext)
86268607 initParser.emplace (*this , initContext);
8627-
86288608
86298609 SourceLoc EqualLoc = consumeToken (tok::equal);
86308610 PBDEntries.back ().setEqualLoc (EqualLoc);
0 commit comments