Skip to content

Commit 6a8598a

Browse files
committed
[NFC] Remove DeclNameRef staging calls
1 parent addbe3e commit 6a8598a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+146
-179
lines changed

include/swift/AST/Decl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,7 @@ class ValueDecl : public Decl {
24622462
/// Generates a DeclNameRef referring to this declaration with as much
24632463
/// specificity as possible.
24642464
DeclNameRef createNameRef() const {
2465-
return DeclNameRef_(getFullName());
2465+
return DeclNameRef(getFullName());
24662466
}
24672467

24682468
/// Retrieve the name to use for this declaration when interoperating

include/swift/AST/DiagnosticEngine.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ namespace swift {
138138

139139
DiagnosticArgument(DeclName D)
140140
: Kind(DiagnosticArgumentKind::Identifier),
141-
IdentifierVal(DeclNameRef_(D)) {}
141+
IdentifierVal(DeclNameRef(D)) {}
142142

143143
DiagnosticArgument(DeclBaseName D)
144144
: Kind(DiagnosticArgumentKind::Identifier),
145-
IdentifierVal(DeclNameRef_(D)) {}
145+
IdentifierVal(DeclNameRef(D)) {}
146146

147147
DiagnosticArgument(Identifier I)
148148
: Kind(DiagnosticArgumentKind::Identifier),
149-
IdentifierVal(DeclNameRef_(I)) {
149+
IdentifierVal(DeclNameRef(I)) {
150150
}
151151

152152
DiagnosticArgument(ObjCSelector S)

include/swift/AST/Expr.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ class UnresolvedDeclRefExpr : public Expr {
15031503
static UnresolvedDeclRefExpr *createImplicit(
15041504
ASTContext &C, DeclName name,
15051505
DeclRefKind refKind = DeclRefKind::Ordinary) {
1506-
return new (C) UnresolvedDeclRefExpr(DeclNameRef_(name), refKind,
1506+
return new (C) UnresolvedDeclRefExpr(DeclNameRef(name), refKind,
15071507
DeclNameLoc());
15081508
}
15091509

@@ -2430,7 +2430,7 @@ class UnresolvedDotExpr : public Expr {
24302430
static UnresolvedDotExpr *createImplicit(
24312431
ASTContext &C, Expr *base, DeclName name) {
24322432
return new (C) UnresolvedDotExpr(base, SourceLoc(),
2433-
DeclNameRef_(name), DeclNameLoc(),
2433+
DeclNameRef(name), DeclNameLoc(),
24342434
/*implicit=*/true);
24352435
}
24362436

include/swift/AST/Identifier.h

+10-33
Original file line numberDiff line numberDiff line change
@@ -638,26 +638,15 @@ class DeclNameRef {
638638
void *getOpaqueValue() const { return FullName.getOpaqueValue(); }
639639
static DeclNameRef getFromOpaqueValue(void *p);
640640

641-
// *** TRANSITIONAL CODE STARTS HERE ***
642-
643-
// We want all DeclNameRef constructions to be explicit, but they need to be
644-
// threaded through large portions of the compiler, so that would be
645-
// difficult. Instead, we will make uses of DeclNameRef(...) implicit but
646-
// deprecated, and use DeclNameRef_(...) as a stand-in for intentional calls
647-
// to the constructors. The deprecations and DeclNameRef_ function will go
648-
// away before we merge any of this into master.
649-
650-
[[deprecated]] DeclNameRef(DeclName FullName)
641+
explicit DeclNameRef(DeclName FullName)
651642
: FullName(FullName) { }
652643

653-
[[deprecated]] DeclNameRef(DeclBaseName BaseName)
644+
explicit DeclNameRef(DeclBaseName BaseName)
654645
: FullName(BaseName) { }
655646

656-
[[deprecated]] DeclNameRef(Identifier BaseName)
647+
explicit DeclNameRef(Identifier BaseName)
657648
: FullName(BaseName) { }
658649

659-
// *** TRANSITIONAL CODE ENDS HERE ***
660-
661650
/// The name of the declaration being referenced.
662651
DeclName getFullName() const {
663652
return FullName;
@@ -775,38 +764,26 @@ class DeclNameRef {
775764
"only for use within the debugger");
776765
};
777766

778-
// *** TRANSITIONAL CODE STARTS HERE ***
779-
780-
template<typename T>
781-
static DeclNameRef DeclNameRef_(T name) {
782-
#pragma clang diagnostic push
783-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
784-
return DeclNameRef(name);
785-
#pragma clang diagnostic pop
786-
}
787-
788-
// *** TRANSITIONAL CODE ENDS HERE ***
789-
790767
inline DeclNameRef DeclNameRef::getFromOpaqueValue(void *p) {
791-
return DeclNameRef_(DeclName::getFromOpaqueValue(p));
768+
return DeclNameRef(DeclName::getFromOpaqueValue(p));
792769
}
793770

794771
inline DeclNameRef DeclNameRef::withoutArgumentLabels() const {
795-
return DeclNameRef_(getBaseName());
772+
return DeclNameRef(getBaseName());
796773
}
797774

798775
inline DeclNameRef DeclNameRef::withArgumentLabels(
799776
ASTContext &C, ArrayRef<Identifier> argumentNames) const {
800-
return DeclNameRef_(DeclName(C, getBaseName(), argumentNames));
777+
return DeclNameRef(DeclName(C, getBaseName(), argumentNames));
801778
}
802779

803780

804781
inline DeclNameRef DeclNameRef::createSubscript() {
805-
return DeclNameRef_(DeclBaseName::createSubscript());
782+
return DeclNameRef(DeclBaseName::createSubscript());
806783
}
807784

808785
inline DeclNameRef DeclNameRef::createConstructor() {
809-
return DeclNameRef_(DeclBaseName::createConstructor());
786+
return DeclNameRef(DeclBaseName::createConstructor());
810787
}
811788

812789
void simple_display(llvm::raw_ostream &out, DeclNameRef name);
@@ -972,10 +949,10 @@ namespace llvm {
972949
// DeclNameRefs hash just like DeclNames.
973950
template<> struct DenseMapInfo<swift::DeclNameRef> {
974951
static swift::DeclNameRef getEmptyKey() {
975-
return DeclNameRef_(DenseMapInfo<swift::DeclName>::getEmptyKey());
952+
return swift::DeclNameRef(DenseMapInfo<swift::DeclName>::getEmptyKey());
976953
}
977954
static swift::DeclNameRef getTombstoneKey() {
978-
return DeclNameRef_(DenseMapInfo<swift::DeclName>::getTombstoneKey());
955+
return swift::DeclNameRef(DenseMapInfo<swift::DeclName>::getTombstoneKey());
979956
}
980957
static unsigned getHashValue(swift::DeclNameRef Val) {
981958
return DenseMapInfo<swift::DeclName>::getHashValue(Val.getFullName());

lib/AST/ASTContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ DECLTYPE *ASTContext::get##NAME##Decl() const { \
833833
/* Note: lookupQualified() will search both the Swift overlay \
834834
* and the Clang module it imports. */ \
835835
SmallVector<ValueDecl *, 1> decls; \
836-
M->lookupQualified(M, DeclNameRef_(getIdentifier(#NAME)), NL_OnlyTypes, \
836+
M->lookupQualified(M, DeclNameRef(getIdentifier(#NAME)), NL_OnlyTypes, \
837837
decls); \
838838
if (decls.size() == 1 && isa<DECLTYPE>(decls[0])) { \
839839
auto decl = cast<DECLTYPE>(decls[0]); \

lib/AST/DocComment.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ const ValueDecl *findDefaultProvidedDeclWithDocComment(const ValueDecl *VD) {
414414

415415
SmallVector<ValueDecl *, 2> members;
416416
protocol->lookupQualified(const_cast<ProtocolDecl *>(protocol),
417-
DeclNameRef_(VD->getFullName()),
417+
DeclNameRef(VD->getFullName()),
418418
NLOptions::NL_ProtocolMembers,
419419
members);
420420

lib/AST/GenericSignatureBuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ TypeDecl *EquivalenceClass::lookupNestedType(
18861886
if (decl) {
18871887
SmallVector<ValueDecl *, 2> foundMembers;
18881888
decl->getParentModule()->lookupQualified(
1889-
decl, DeclNameRef_(name),
1889+
decl, DeclNameRef(name),
18901890
NL_QualifiedDefault | NL_OnlyTypes | NL_ProtocolMembers,
18911891
foundMembers);
18921892
for (auto member : foundMembers) {

lib/AST/NameLookup.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ CustomAttrNominalRequest::evaluate(Evaluator &evaluator,
23312331

23322332
ComponentIdentTypeRepr *components[2] = {
23332333
new (ctx) SimpleIdentTypeRepr(identTypeRepr->getNameLoc(),
2334-
DeclNameRef_(moduleName)),
2334+
DeclNameRef(moduleName)),
23352335
identTypeRepr
23362336
};
23372337

lib/AST/TypeRepr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ DeclNameRef ComponentIdentTypeRepr::getNameRef() const {
8383
if (IdOrDecl.is<DeclNameRef>())
8484
return IdOrDecl.get<DeclNameRef>();
8585

86-
return DeclNameRef_(IdOrDecl.get<TypeDecl *>()->getFullName());
86+
return IdOrDecl.get<TypeDecl *>()->createNameRef();
8787
}
8888

8989
static void printTypeRepr(const TypeRepr *TyR, ASTPrinter &Printer,

lib/ClangImporter/ImportDecl.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -5017,7 +5017,7 @@ namespace {
50175017

50185018
if (lookupContext) {
50195019
SmallVector<ValueDecl *, 2> lookup;
5020-
dc->lookupQualified(lookupContext, DeclNameRef_(name),
5020+
dc->lookupQualified(lookupContext, DeclNameRef(name),
50215021
NL_QualifiedDefault | NL_KnownNoDependency,
50225022
lookup);
50235023
bool foundMethod = false;
@@ -6396,7 +6396,7 @@ void SwiftDeclConverter::recordObjCOverride(AbstractFunctionDecl *decl) {
63966396
return;
63976397
// Dig out the Objective-C superclass.
63986398
SmallVector<ValueDecl *, 4> results;
6399-
superDecl->lookupQualified(superDecl, DeclNameRef_(decl->getFullName()),
6399+
superDecl->lookupQualified(superDecl, DeclNameRef(decl->getFullName()),
64006400
NL_QualifiedDefault | NL_KnownNoDependency,
64016401
results);
64026402
for (auto member : results) {
@@ -6469,7 +6469,7 @@ void SwiftDeclConverter::recordObjCOverride(SubscriptDecl *subscript) {
64696469
// operation.
64706470
SmallVector<ValueDecl *, 2> lookup;
64716471
subscript->getModuleContext()->lookupQualified(
6472-
superDecl, DeclNameRef_(subscript->getFullName()),
6472+
superDecl, DeclNameRef(subscript->getFullName()),
64736473
NL_QualifiedDefault | NL_KnownNoDependency, lookup);
64746474

64756475
for (auto result : lookup) {
@@ -7752,7 +7752,7 @@ static void finishTypeWitnesses(
77527752
NL_OnlyTypes |
77537753
NL_ProtocolMembers);
77547754

7755-
dc->lookupQualified(nominal, DeclNameRef_(assocType->getFullName()), options,
7755+
dc->lookupQualified(nominal, DeclNameRef(assocType->getFullName()), options,
77567756
lookupResults);
77577757
for (auto member : lookupResults) {
77587758
auto typeDecl = cast<TypeDecl>(member);

lib/IDE/ExprContextAnalysis.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static bool collectPossibleCalleesForApply(
393393
} else if (auto *DSCE = dyn_cast<DotSyntaxCallExpr>(fnExpr)) {
394394
if (auto *DRE = dyn_cast<DeclRefExpr>(DSCE->getFn())) {
395395
collectPossibleCalleesByQualifiedLookup(
396-
DC, DSCE->getArg(), DeclNameRef_(DRE->getDecl()->getFullName()),
396+
DC, DSCE->getArg(), DeclNameRef(DRE->getDecl()->getFullName()),
397397
candidates);
398398
}
399399
}

lib/IDE/SourceEntityWalker.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class SemaAnnotator : public ASTWalker {
7474
bool passReference(ValueDecl *D, Type Ty, SourceLoc Loc, SourceRange Range,
7575
ReferenceMetaData Data);
7676
bool passReference(ValueDecl *D, Type Ty, DeclNameLoc Loc, ReferenceMetaData Data);
77-
bool passReference(ModuleEntity Mod, std::pair<DeclNameRef, SourceLoc> IdLoc);
77+
bool passReference(ModuleEntity Mod, std::pair<Identifier, SourceLoc> IdLoc);
7878

7979
bool passSubscriptReference(ValueDecl *D, SourceLoc Loc,
8080
ReferenceMetaData Data, bool IsOpenBracket);
@@ -489,9 +489,10 @@ bool SemaAnnotator::walkToTypeReprPre(TypeRepr *T) {
489489

490490
if (auto IdT = dyn_cast<ComponentIdentTypeRepr>(T)) {
491491
if (ValueDecl *VD = IdT->getBoundDecl()) {
492-
if (auto *ModD = dyn_cast<ModuleDecl>(VD))
493-
return passReference(ModD, std::make_pair(IdT->getNameRef(),
494-
IdT->getLoc()));
492+
if (auto *ModD = dyn_cast<ModuleDecl>(VD)) {
493+
auto ident = IdT->getNameRef().getBaseIdentifier();
494+
return passReference(ModD, std::make_pair(ident, IdT->getLoc()));
495+
}
495496

496497
return passReference(VD, Type(), IdT->getNameLoc(),
497498
ReferenceMetaData(SemaReferenceKind::TypeRef, None));
@@ -668,10 +669,10 @@ passReference(ValueDecl *D, Type Ty, SourceLoc BaseNameLoc, SourceRange Range,
668669
}
669670

670671
bool SemaAnnotator::passReference(ModuleEntity Mod,
671-
std::pair<DeclNameRef, SourceLoc> IdLoc) {
672+
std::pair<Identifier, SourceLoc> IdLoc) {
672673
if (IdLoc.second.isInvalid())
673674
return true;
674-
unsigned NameLen = IdLoc.first.getBaseIdentifier().getLength();
675+
unsigned NameLen = IdLoc.first.getLength();
675676
CharSourceRange Range{ IdLoc.second, NameLen };
676677
bool Continue = SEWalker.visitModuleReference(Mod, Range);
677678
if (!Continue)

lib/Immediate/REPL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ class REPLEnvironment {
10921092
ASTContext &ctx = CI.getASTContext();
10931093
SourceFile &SF =
10941094
MostRecentModule->getMainSourceFile(SourceFileKind::REPL);
1095-
auto name = DeclNameRef_(ctx.getIdentifier(Tok.getText()));
1095+
DeclNameRef name(ctx.getIdentifier(Tok.getText()));
10961096
auto descriptor = UnqualifiedLookupDescriptor(name, &SF);
10971097
auto lookup = evaluateOrDefault(
10981098
ctx.evaluator, UnqualifiedLookupRequest{descriptor}, {});

lib/Parse/ParseDecl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4045,7 +4045,7 @@ ParserStatus Parser::parseInheritance(SmallVectorImpl<TypeLoc> &Inherited,
40454045

40464046
// Add 'AnyObject' to the inherited list.
40474047
Inherited.push_back(
4048-
new (Context) SimpleIdentTypeRepr(DeclNameLoc(classLoc), DeclNameRef_(
4048+
new (Context) SimpleIdentTypeRepr(DeclNameLoc(classLoc), DeclNameRef(
40494049
Context.getIdentifier("AnyObject"))));
40504050
continue;
40514051
}

lib/Parse/ParseExpr.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,10 @@ UnresolvedDeclRefExpr *Parser::parseExprOperator() {
806806
assert(Tok.isAnyOperator());
807807
DeclRefKind refKind = getDeclRefKindForOperator(Tok.getKind());
808808
SourceLoc loc = Tok.getLoc();
809-
Identifier name = Context.getIdentifier(Tok.getText());
809+
DeclNameRef name(Context.getIdentifier(Tok.getText()));
810810
consumeToken();
811811
// Bypass local lookup.
812-
return new (Context) UnresolvedDeclRefExpr(DeclNameRef_(name), refKind,
813-
DeclNameLoc(loc));
812+
return new (Context) UnresolvedDeclRefExpr(name, refKind, DeclNameLoc(loc));
814813
}
815814

816815
static VarDecl *getImplicitSelfDeclForSuperContext(Parser &P,
@@ -824,7 +823,7 @@ static VarDecl *getImplicitSelfDeclForSuperContext(Parser &P,
824823

825824
// Do an actual lookup for 'self' in case it shows up in a capture list.
826825
auto *methodSelf = methodContext->getImplicitSelfDecl();
827-
auto *lookupSelf = P.lookupInScope(DeclNameRef_(P.Context.Id_self));
826+
auto *lookupSelf = P.lookupInScope(DeclNameRef(P.Context.Id_self));
828827
if (lookupSelf && lookupSelf != methodSelf) {
829828
// FIXME: This is the wrong diagnostic for if someone manually declares a
830829
// variable named 'self' using backticks.
@@ -1074,7 +1073,7 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
10741073

10751074
// Handle "x.42" - a tuple index.
10761075
if (Tok.is(tok::integer_literal)) {
1077-
auto name = DeclNameRef_(Context.getIdentifier(Tok.getText()));
1076+
DeclNameRef name(Context.getIdentifier(Tok.getText()));
10781077
SourceLoc nameLoc = consumeToken(tok::integer_literal);
10791078
SyntaxContext->createNodeInPlace(SyntaxKind::MemberAccessExpr);
10801079

@@ -1753,9 +1752,9 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
17531752
ParsedTrivia EmptyTrivia;
17541753
bool First = true;
17551754

1756-
auto appendLiteral = DeclNameRef_(DeclName(Context, Context.Id_appendLiteral,
1757-
{ Identifier() }));
1758-
auto appendInterpolation = DeclNameRef_(Context.Id_appendInterpolation);
1755+
DeclNameRef appendLiteral(
1756+
{ Context, Context.Id_appendLiteral, { Identifier() } });
1757+
DeclNameRef appendInterpolation(Context.Id_appendInterpolation);
17591758

17601759
for (auto Segment : Segments) {
17611760
auto InterpolationVarRef =
@@ -2117,7 +2116,7 @@ DeclNameRef Parser::parseUnqualifiedDeclBaseName(
21172116
}
21182117

21192118
loc = DeclNameLoc(baseNameLoc);
2120-
return DeclNameRef_(baseName);
2119+
return DeclNameRef(baseName);
21212120
}
21222121

21232122

@@ -2897,7 +2896,7 @@ Expr *Parser::parseExprAnonClosureArg() {
28972896
if (Context.LangOpts.DebuggerSupport) {
28982897
auto refKind = DeclRefKind::Ordinary;
28992898
auto identifier = Context.getIdentifier(Name);
2900-
return new (Context) UnresolvedDeclRefExpr(DeclNameRef_(identifier),
2899+
return new (Context) UnresolvedDeclRefExpr(DeclNameRef(identifier),
29012900
refKind, DeclNameLoc(Loc));
29022901
}
29032902
diagnose(Loc, diag::anon_closure_arg_not_in_closure);

lib/Parse/Parser.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,6 @@ DeclName swift::formDeclName(ASTContext &ctx,
13711371

13721372
DeclNameRef swift::formDeclNameRef(ASTContext &ctx,
13731373
StringRef baseName,
1374-
13751374
ArrayRef<StringRef> argumentLabels,
13761375
bool isFunctionName,
13771376
bool isInitializer) {
@@ -1387,7 +1386,7 @@ DeclNameRef swift::formDeclNameRef(ASTContext &ctx,
13871386
: ctx.getIdentifier(baseName));
13881387

13891388
// For non-functions, just use the base name.
1390-
if (!isFunctionName) return DeclNameRef_(baseNameId);
1389+
if (!isFunctionName) return DeclNameRef(baseNameId);
13911390

13921391
// For functions, we need to form a complete name.
13931392

@@ -1403,7 +1402,7 @@ DeclNameRef swift::formDeclNameRef(ASTContext &ctx,
14031402
}
14041403

14051404
// Build the result.
1406-
return DeclNameRef_(DeclName(ctx, baseNameId, argumentLabelIds));
1405+
return DeclNameRef({ ctx, baseNameId, argumentLabelIds });
14071406
}
14081407

14091408
DeclName swift::parseDeclName(ASTContext &ctx, StringRef name) {

lib/ParseSIL/ParseSIL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ lookupTopDecl(Parser &P, DeclBaseName Name, bool typeLookup) {
11871187
options |= UnqualifiedLookupFlags::TypeLookup;
11881188

11891189
auto &ctx = P.SF.getASTContext();
1190-
auto descriptor = UnqualifiedLookupDescriptor(DeclNameRef_(Name), &P.SF);
1190+
auto descriptor = UnqualifiedLookupDescriptor(DeclNameRef(Name), &P.SF);
11911191
auto lookup = evaluateOrDefault(ctx.evaluator,
11921192
UnqualifiedLookupRequest{descriptor}, {});
11931193
assert(lookup.size() == 1);

lib/SIL/SILFunctionType.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static CanType getKnownType(Optional<CanType> &cacheSlot, ASTContext &C,
203203
// lookupValue would only give us types actually declared in the overlays
204204
// themselves.
205205
SmallVector<ValueDecl *, 2> decls;
206-
mod->lookupQualified(mod, DeclNameRef_(C.getIdentifier(typeName)),
206+
mod->lookupQualified(mod, DeclNameRef(C.getIdentifier(typeName)),
207207
NL_QualifiedDefault | NL_KnownNonCascadingDependency,
208208
decls);
209209
if (decls.size() != 1)

lib/SILGen/SILGenFunction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
550550
assert(UIKit && "couldn't find UIKit objc module?!");
551551
SmallVector<ValueDecl *, 1> results;
552552
UIKit->lookupQualified(UIKit,
553-
DeclNameRef_(ctx.getIdentifier("UIApplicationMain")),
553+
DeclNameRef(ctx.getIdentifier("UIApplicationMain")),
554554
NL_QualifiedDefault,
555555
results);
556556
assert(results.size() == 1

0 commit comments

Comments
 (0)