[AST] Rename SubscriptDecl::create -> createParsed

And generate the DeclName using the argument labels
on the ParameterList.
This commit is contained in:
Hamish Knight
2023-12-15 19:53:52 +00:00
parent 9710a6575d
commit 8fdb48d910
3 changed files with 18 additions and 23 deletions

View File

@@ -6843,13 +6843,12 @@ public:
Type ElementTy, DeclContext *Parent, Type ElementTy, DeclContext *Parent,
GenericParamList *GenericParams); GenericParamList *GenericParams);
static SubscriptDecl *create(ASTContext &Context, DeclName Name, static SubscriptDecl *createParsed(ASTContext &Context, SourceLoc StaticLoc,
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
StaticSpellingKind StaticSpelling, SourceLoc SubscriptLoc,
SourceLoc SubscriptLoc, ParameterList *Indices, ParameterList *Indices, SourceLoc ArrowLoc,
SourceLoc ArrowLoc, TypeRepr *ElementTyR, TypeRepr *ElementTyR, DeclContext *Parent,
DeclContext *Parent, GenericParamList *GenericParams);
GenericParamList *GenericParams);
static SubscriptDecl *create(ASTContext &Context, DeclName Name, static SubscriptDecl *create(ASTContext &Context, DeclName Name,
SourceLoc StaticLoc, SourceLoc StaticLoc,

View File

@@ -8812,14 +8812,13 @@ SubscriptDecl::createDeserialized(ASTContext &Context, DeclName Name,
return SD; return SD;
} }
SubscriptDecl *SubscriptDecl::create(ASTContext &Context, DeclName Name, SubscriptDecl *SubscriptDecl::createParsed(
SourceLoc StaticLoc, ASTContext &Context, SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
StaticSpellingKind StaticSpelling, SourceLoc SubscriptLoc, ParameterList *Indices, SourceLoc ArrowLoc,
SourceLoc SubscriptLoc, TypeRepr *ElementTyR, DeclContext *Parent,
ParameterList *Indices, SourceLoc ArrowLoc, GenericParamList *GenericParams) {
TypeRepr *ElementTyR, DeclContext *Parent,
GenericParamList *GenericParams) {
assert(ElementTyR); assert(ElementTyR);
auto Name = DeclName(Context, DeclBaseName::createSubscript(), Indices);
auto *const SD = new (Context) auto *const SD = new (Context)
SubscriptDecl(Name, StaticLoc, StaticSpelling, SubscriptLoc, Indices, SubscriptDecl(Name, StaticLoc, StaticSpelling, SubscriptLoc, Indices,
ArrowLoc, ElementTyR, Parent, GenericParams); ArrowLoc, ElementTyR, Parent, GenericParams);

View File

@@ -9508,10 +9508,9 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc,
// Parse the parameter list. // Parse the parameter list.
DefaultArgumentInfo DefaultArgs; DefaultArgumentInfo DefaultArgs;
SmallVector<Identifier, 4> argumentNames; ParserResult<ParameterList> Indices =
ParserResult<ParameterList> Indices parseSingleParameterClause(ParameterContextKind::Subscript,
= parseSingleParameterClause(ParameterContextKind::Subscript, /*argumentNamesOut*/ nullptr, &DefaultArgs);
&argumentNames, &DefaultArgs);
Status |= Indices; Status |= Indices;
if (Status.hasCodeCompletion() && !CodeCompletionCallbacks) if (Status.hasCodeCompletion() && !CodeCompletionCallbacks)
return Status; return Status;
@@ -9554,11 +9553,9 @@ Parser::parseDeclSubscript(SourceLoc StaticLoc,
} }
// Build an AST for the subscript declaration. // Build an AST for the subscript declaration.
DeclName name = DeclName(Context, DeclBaseName::createSubscript(), auto *const Subscript = SubscriptDecl::createParsed(
argumentNames); Context, StaticLoc, StaticSpelling, SubscriptLoc, Indices.get(), ArrowLoc,
auto *const Subscript = SubscriptDecl::create( ElementTy.get(), CurDeclContext, GenericParams);
Context, name, StaticLoc, StaticSpelling, SubscriptLoc, Indices.get(),
ArrowLoc, ElementTy.get(), CurDeclContext, GenericParams);
Subscript->getAttrs() = Attributes; Subscript->getAttrs() = Attributes;
// Let the source file track the opaque return type mapping, if any. // Let the source file track the opaque return type mapping, if any.