Skip to content

Commit c30e592

Browse files
committed
[NFC] Give withoutArgumentLabels() a context arg
It will soon need to allocate sometimes. # Conflicts: # lib/IDE/ExprContextAnalysis.cpp
1 parent 563e7eb commit c30e592

File tree

6 files changed

+11
-10
lines changed

6 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
@@ -747,7 +747,7 @@ class DeclNameRef {
747747
return lhs.compare(rhs) >= 0;
748748
}
749749

750-
DeclNameRef withoutArgumentLabels() const;
750+
DeclNameRef withoutArgumentLabels(ASTContext &C) const;
751751
DeclNameRef withArgumentLabels(ASTContext &C,
752752
ArrayRef<Identifier> argumentNames) const;
753753

@@ -781,7 +781,7 @@ inline DeclNameRef DeclNameRef::getFromOpaqueValue(void *p) {
781781
return DeclNameRef(DeclName::getFromOpaqueValue(p));
782782
}
783783

784-
inline DeclNameRef DeclNameRef::withoutArgumentLabels() const {
784+
inline DeclNameRef DeclNameRef::withoutArgumentLabels(ASTContext &C) const {
785785
return DeclNameRef(getBaseName());
786786
}
787787

@@ -790,7 +790,6 @@ inline DeclNameRef DeclNameRef::withArgumentLabels(
790790
return DeclNameRef(DeclName(C, getBaseName(), argumentNames));
791791
}
792792

793-
794793
inline DeclNameRef DeclNameRef::createSubscript() {
795794
return DeclNameRef(DeclBaseName::createSubscript());
796795
}

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static void collectPossibleCalleesByQualifiedLookup(
448448

449449
SmallVector<ValueDecl *, 2> decls;
450450
if (!DC.lookupQualified(baseInstanceTy,
451-
name.withoutArgumentLabels(),
451+
name.withoutArgumentLabels(DC.getASTContext()),
452452
NL_QualifiedDefault | NL_ProtocolMembers,
453453
decls))
454454
return;

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,8 @@ bool MissingMemberFailure::diagnoseAsError() {
36623662
auto &cs = getConstraintSystem();
36633663

36643664
auto result = cs.performMemberLookup(
3665-
ConstraintKind::ValueMember, getName().withoutArgumentLabels(),
3665+
ConstraintKind::ValueMember,
3666+
getName().withoutArgumentLabels(getASTContext()),
36663667
metatypeTy, FunctionRefKind::DoubleApply, getLocator(),
36673668
/*includeInaccessibleMembers=*/true);
36683669

lib/Sema/TypeCheckAttr.cpp

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

5741+
auto &ctx = attached->getASTContext();
57415742
auto attachedContext = attached->getDeclContext();
57425743
auto parsedName = parseDeclName(attr->Rename);
5743-
auto nameRef = parsedName.formDeclNameRef(attached->getASTContext());
5744+
auto nameRef = parsedName.formDeclNameRef(ctx);
57445745

57455746
// Handle types separately
57465747
if (isa<NominalTypeDecl>(attached)) {
@@ -5749,7 +5750,7 @@ ValueDecl *RenamedDeclRequest::evaluate(Evaluator &evaluator,
57495750

57505751
SmallVector<ValueDecl *, 1> lookupResults;
57515752
attachedContext->lookupQualified(attachedContext->getParentModule(),
5752-
nameRef.withoutArgumentLabels(),
5753+
nameRef.withoutArgumentLabels(ctx),
57535754
NL_OnlyTypes, lookupResults);
57545755
if (lookupResults.size() == 1)
57555756
return lookupResults[0];

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static EnumElementDecl *
119119
lookupUnqualifiedEnumMemberElement(DeclContext *DC, DeclNameRef name,
120120
SourceLoc UseLoc) {
121121
// FIXME: We should probably pay attention to argument labels someday.
122-
name = name.withoutArgumentLabels();
122+
name = name.withoutArgumentLabels(DC->getASTContext());
123123

124124
auto lookup =
125125
TypeChecker::lookupUnqualified(DC, name, UseLoc,
@@ -136,7 +136,7 @@ lookupEnumMemberElement(DeclContext *DC, Type ty,
136136
return nullptr;
137137

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

141141
// Look up the case inside the enum.
142142
// 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
@@ -1228,7 +1228,7 @@ WitnessChecker::lookupValueWitnesses(ValueDecl *req, bool *ignoringNames) {
12281228
lookupValueWitnessesViaImplementsAttr(req, witnesses);
12291229

12301230
auto reqName = req->createNameRef();
1231-
auto reqBaseName = reqName.withoutArgumentLabels();
1231+
auto reqBaseName = reqName.withoutArgumentLabels(DC->getASTContext());
12321232

12331233
if (req->isOperator()) {
12341234
// Operator lookup is always global.

0 commit comments

Comments
 (0)