Skip to content

Commit 96cc3bf

Browse files
committed
[NFC] Give withoutArgumentLabels() a context arg
It will soon need to allocate sometimes.
1 parent b0148b3 commit 96cc3bf

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

include/swift/AST/Identifier.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ class DeclNameRef {
791791
return lhs.compare(rhs) >= 0;
792792
}
793793

794-
DeclNameRef withoutArgumentLabels() const;
794+
DeclNameRef withoutArgumentLabels(ASTContext &C) const;
795795
DeclNameRef withArgumentLabels(ASTContext &C,
796796
ArrayRef<Identifier> argumentNames) const;
797797

@@ -824,7 +824,7 @@ inline DeclNameRef DeclNameRef::getFromOpaqueValue(void *p) {
824824
return DeclNameRef(DeclName::getFromOpaqueValue(p));
825825
}
826826

827-
inline DeclNameRef DeclNameRef::withoutArgumentLabels() const {
827+
inline DeclNameRef DeclNameRef::withoutArgumentLabels(ASTContext &C) const {
828828
return DeclNameRef(getBaseName());
829829
}
830830

@@ -833,7 +833,6 @@ inline DeclNameRef DeclNameRef::withArgumentLabels(
833833
return DeclNameRef(DeclName(C, getBaseName(), argumentNames));
834834
}
835835

836-
837836
inline DeclNameRef DeclNameRef::createSubscript() {
838837
return DeclNameRef(DeclBaseName::createSubscript());
839838
}

lib/Sema/CSDiagnostics.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,8 +4449,9 @@ bool MissingMemberFailure::diagnoseAsError() {
44494449
auto &cs = getConstraintSystem();
44504450

44514451
auto result = cs.performMemberLookup(
4452-
ConstraintKind::ValueMember, getName().withoutArgumentLabels(),
4453-
metatypeTy, FunctionRefInfo::doubleBaseNameApply(), getLocator(),
4452+
ConstraintKind::ValueMember,
4453+
getName().withoutArgumentLabels(getASTContext()), metatypeTy,
4454+
FunctionRefInfo::doubleBaseNameApply(), getLocator(),
44544455
/*includeInaccessibleMembers=*/true);
44554456

44564457
// If there are no `init` members at all produce a tailored

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8389,9 +8389,10 @@ ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
83898389
if (attr->Rename.empty())
83908390
return nullptr;
83918391

8392+
auto &ctx = attached->getASTContext();
83928393
auto attachedContext = attached->getDeclContext();
83938394
auto parsedName = parseDeclName(attr->Rename);
8394-
auto nameRef = parsedName.formDeclNameRef(attached->getASTContext());
8395+
auto nameRef = parsedName.formDeclNameRef(ctx);
83958396

83968397
// Handle types separately
83978398
if (isa<NominalTypeDecl>(attached)) {
@@ -8400,7 +8401,7 @@ ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
84008401

84018402
SmallVector<ValueDecl *, 1> lookupResults;
84028403
attachedContext->lookupQualified(attachedContext->getParentModule(),
8403-
nameRef.withoutArgumentLabels(),
8404+
nameRef.withoutArgumentLabels(ctx),
84048405
attr->getLocation(), NL_OnlyTypes,
84058406
lookupResults);
84068407
if (lookupResults.size() == 1)

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static EnumElementDecl *
138138
lookupUnqualifiedEnumMemberElement(DeclContext *DC, DeclNameRef name,
139139
SourceLoc UseLoc) {
140140
// FIXME: We should probably pay attention to argument labels someday.
141-
name = name.withoutArgumentLabels();
141+
name = name.withoutArgumentLabels(DC->getASTContext());
142142

143143
auto lookup =
144144
TypeChecker::lookupUnqualified(DC, name, UseLoc,
@@ -153,7 +153,7 @@ static LookupResult lookupMembers(DeclContext *DC, Type ty, DeclNameRef name,
153153
return LookupResult();
154154

155155
// FIXME: We should probably pay attention to argument labels someday.
156-
name = name.withoutArgumentLabels();
156+
name = name.withoutArgumentLabels(DC->getASTContext());
157157

158158
// Look up the case inside the enum.
159159
// FIXME: We should be able to tell if this is a private lookup.

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ swift::lookupValueWitnesses(DeclContext *DC, ValueDecl *req, bool *ignoringNames
14891489
lookupValueWitnessesViaImplementsAttr(DC, req, witnesses);
14901490

14911491
auto reqName = req->createNameRef();
1492-
auto reqBaseName = reqName.withoutArgumentLabels();
1492+
auto reqBaseName = reqName.withoutArgumentLabels(DC->getASTContext());
14931493

14941494
// An operator function is the only kind of witness that requires global
14951495
// lookup. However, because global lookup doesn't enter local contexts,

0 commit comments

Comments
 (0)