Skip to content

Commit 7425202

Browse files
committed
AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl
1 parent 52c3d70 commit 7425202

File tree

90 files changed

+457
-462
lines changed

Some content is hidden

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

90 files changed

+457
-462
lines changed

include/swift/AST/Decl.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -2503,8 +2503,7 @@ class ValueDecl : public Decl {
25032503
bool isOperator() const { return Name.isOperator(); }
25042504

25052505
/// Retrieve the full name of the declaration.
2506-
/// TODO: Rename to getName?
2507-
DeclName getFullName() const { return Name; }
2506+
DeclName getName() const { return Name; }
25082507
void setName(DeclName name) { Name = name; }
25092508

25102509
/// Retrieve the base name of the declaration, ignoring any argument
@@ -2518,7 +2517,7 @@ class ValueDecl : public Decl {
25182517
/// Generates a DeclNameRef referring to this declaration with as much
25192518
/// specificity as possible.
25202519
DeclNameRef createNameRef() const {
2521-
return DeclNameRef(getFullName());
2520+
return DeclNameRef(Name);
25222521
}
25232522

25242523
/// Retrieve the name to use for this declaration when interoperating
@@ -2847,7 +2846,6 @@ class TypeDecl : public ValueDecl {
28472846

28482847
/// Returns the string for the base name, or "_" if this is unnamed.
28492848
StringRef getNameStr() const {
2850-
assert(!getFullName().isSpecial() && "Cannot get string for special names");
28512849
return hasName() ? getBaseIdentifier().str() : "_";
28522850
}
28532851

@@ -4950,7 +4948,6 @@ class VarDecl : public AbstractStorageDecl {
49504948

49514949
/// Returns the string for the base name, or "_" if this is unnamed.
49524950
StringRef getNameStr() const {
4953-
assert(!getFullName().isSpecial() && "Cannot get string for special names");
49544951
return hasName() ? getBaseIdentifier().str() : "_";
49554952
}
49564953

@@ -5925,7 +5922,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
59255922

59265923
/// Returns the string for the base name, or "_" if this is unnamed.
59275924
StringRef getNameStr() const {
5928-
assert(!getFullName().isSpecial() && "Cannot get string for special names");
5925+
assert(!getName().isSpecial() && "Cannot get string for special names");
59295926
return hasName() ? getBaseIdentifier().str() : "_";
59305927
}
59315928

@@ -6625,7 +6622,7 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
66256622

66266623
/// Returns the string for the base name, or "_" if this is unnamed.
66276624
StringRef getNameStr() const {
6628-
assert(!getFullName().isSpecial() && "Cannot get string for special names");
6625+
assert(!getName().isSpecial() && "Cannot get string for special names");
66296626
return hasName() ? getBaseIdentifier().str() : "_";
66306627
}
66316628

@@ -7378,7 +7375,7 @@ class MissingMemberDecl : public Decl {
73787375
return new (ctx) MissingMemberDecl(DC, name, numVTableEntries, hasStorage);
73797376
}
73807377

7381-
DeclName getFullName() const {
7378+
DeclName getName() const {
73827379
return Name;
73837380
}
73847381

include/swift/AST/NameLookup.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ class NamedDeclConsumer : public VisibleDeclConsumer {
419419
// to avoid circular validation.
420420
if (isTypeLookup && !isa<TypeDecl>(VD))
421421
return;
422-
if (VD->getFullName().matchesRef(name.getFullName()))
422+
if (VD->getName().matchesRef(name.getFullName()))
423423
results.push_back(LookupResultEntry(VD));
424424
}
425425
};

lib/AST/ASTDumper.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,9 @@ namespace {
619619
}
620620

621621
void printDeclName(const ValueDecl *D) {
622-
if (D->getFullName()) {
622+
if (D->getName()) {
623623
PrintWithColorRAII(OS, IdentifierColor)
624-
<< '\"' << D->getFullName() << '\"';
624+
<< '\"' << D->getName() << '\"';
625625
} else {
626626
PrintWithColorRAII(OS, IdentifierColor)
627627
<< "'anonname=" << (const void*)D << '\'';
@@ -1105,7 +1105,7 @@ namespace {
11051105
void visitAccessorDecl(AccessorDecl *AD) {
11061106
printCommonFD(AD, "accessor_decl");
11071107
OS << " " << getAccessorKindString(AD->getAccessorKind());
1108-
OS << "_for=" << AD->getStorage()->getFullName();
1108+
OS << "_for=" << AD->getStorage()->getName();
11091109
printAbstractFunctionDecl(AD);
11101110
PrintWithColorRAII(OS, ParenthesisColor) << ')';
11111111
}
@@ -1268,7 +1268,7 @@ namespace {
12681268
void visitMissingMemberDecl(MissingMemberDecl *MMD) {
12691269
printCommon(MMD, "missing_member_decl ");
12701270
PrintWithColorRAII(OS, IdentifierColor)
1271-
<< '\"' << MMD->getFullName() << '\"';
1271+
<< '\"' << MMD->getName() << '\"';
12721272
PrintWithColorRAII(OS, ParenthesisColor) << ')';
12731273
}
12741274
};
@@ -1367,15 +1367,15 @@ void swift::printContext(raw_ostream &os, DeclContext *dc) {
13671367
break;
13681368

13691369
case DeclContextKind::AbstractFunctionDecl:
1370-
printName(os, cast<AbstractFunctionDecl>(dc)->getFullName());
1370+
printName(os, cast<AbstractFunctionDecl>(dc)->getName());
13711371
break;
13721372

13731373
case DeclContextKind::SubscriptDecl:
1374-
printName(os, cast<SubscriptDecl>(dc)->getFullName());
1374+
printName(os, cast<SubscriptDecl>(dc)->getName());
13751375
break;
13761376

13771377
case DeclContextKind::EnumElementDecl:
1378-
printName(os, cast<EnumElementDecl>(dc)->getFullName());
1378+
printName(os, cast<EnumElementDecl>(dc)->getName());
13791379
break;
13801380
}
13811381
}
@@ -1393,7 +1393,7 @@ void ValueDecl::dumpRef(raw_ostream &os) const {
13931393
os << ".";
13941394

13951395
// Print name.
1396-
getFullName().printPretty(os);
1396+
getName().printPretty(os);
13971397

13981398
// Print location.
13991399
auto &srcMgr = getASTContext().SourceMgr;
@@ -3171,7 +3171,7 @@ static void dumpProtocolConformanceRec(
31713171
out << '\n';
31723172
out.indent(indent + 2);
31733173
PrintWithColorRAII(out, ParenthesisColor) << '(';
3174-
out << "value req=" << req->getFullName() << " witness=";
3174+
out << "value req=" << req->getName() << " witness=";
31753175
if (!witness) {
31763176
out << "(none)";
31773177
} else if (witness.getDecl() == req) {

lib/AST/ASTPrinter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,7 @@ void PrintAST::visitModuleDecl(ModuleDecl *decl) { }
32653265

32663266
void PrintAST::visitMissingMemberDecl(MissingMemberDecl *decl) {
32673267
Printer << "/* placeholder for ";
3268-
recordDeclLoc(decl, [&]{ Printer << decl->getFullName(); });
3268+
recordDeclLoc(decl, [&]{ Printer << decl->getName(); });
32693269
unsigned numVTableEntries = decl->getNumberOfVTableEntries();
32703270
if (numVTableEntries > 0)
32713271
Printer << " (vtable entries: " << numVTableEntries << ")";

lib/AST/ASTScopePrinting.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void ASTScopeImpl::dumpOneScopeMapLocation(
6767
llvm::errs() << "Local bindings: ";
6868
llvm::interleave(
6969
gatherer.getDecls().begin(), gatherer.getDecls().end(),
70-
[&](ValueDecl *value) { llvm::errs() << value->getFullName(); },
70+
[&](ValueDecl *value) { llvm::errs() << value->getName(); },
7171
[&]() { llvm::errs() << " "; });
7272
llvm::errs() << "\n";
7373
}
@@ -169,7 +169,7 @@ void GenericParamScope::printSpecifics(llvm::raw_ostream &out) const {
169169
}
170170

171171
void AbstractFunctionDeclScope::printSpecifics(llvm::raw_ostream &out) const {
172-
out << "'" << decl->getFullName() << "'";
172+
out << "'" << decl->getName() << "'";
173173
}
174174

175175
void AbstractPatternEntryScope::printSpecifics(llvm::raw_ostream &out) const {

lib/AST/ASTVerifier.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2814,8 +2814,8 @@ class Verifier : public ASTWalker {
28142814

28152815
// All of the parameter names should match.
28162816
if (!isa<DestructorDecl>(AFD)) { // Destructor has no non-self params.
2817-
auto paramNames = AFD->getFullName().getArgumentNames();
2818-
bool checkParamNames = (bool)AFD->getFullName();
2817+
auto paramNames = AFD->getName().getArgumentNames();
2818+
bool checkParamNames = (bool)AFD->getName();
28192819
auto *firstParams = AFD->getParameters();
28202820

28212821
if (checkParamNames &&

lib/AST/Decl.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,7 @@ static Type mapSignatureFunctionType(ASTContext &ctx, Type type,
27592759
OverloadSignature ValueDecl::getOverloadSignature() const {
27602760
OverloadSignature signature;
27612761

2762-
signature.Name = getFullName();
2762+
signature.Name = getName();
27632763
signature.InProtocolExtension
27642764
= static_cast<bool>(getDeclContext()->getExtendedProtocolDecl());
27652765
signature.IsInstanceMember = isInstanceMember();
@@ -6631,8 +6631,8 @@ SourceRange SubscriptDecl::getSignatureSourceRange() const {
66316631
}
66326632

66336633
DeclName AbstractFunctionDecl::getEffectiveFullName() const {
6634-
if (getFullName())
6635-
return getFullName();
6634+
if (getName())
6635+
return getName();
66366636

66376637
if (auto accessor = dyn_cast<AccessorDecl>(this)) {
66386638
auto &ctx = getASTContext();
@@ -6645,7 +6645,7 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
66456645
case AccessorKind::Get:
66466646
case AccessorKind::Read:
66476647
case AccessorKind::Modify:
6648-
return subscript ? subscript->getFullName()
6648+
return subscript ? subscript->getName()
66496649
: DeclName(ctx, storage->getBaseName(),
66506650
ArrayRef<Identifier>());
66516651

@@ -6657,8 +6657,8 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
66576657
argNames.push_back(Identifier());
66586658
// The subscript index parameters.
66596659
if (subscript) {
6660-
argNames.append(subscript->getFullName().getArgumentNames().begin(),
6661-
subscript->getFullName().getArgumentNames().end());
6660+
argNames.append(subscript->getName().getArgumentNames().begin(),
6661+
subscript->getName().getArgumentNames().end());
66626662
}
66636663
return DeclName(ctx, storage->getBaseName(), argNames);
66646664
}
@@ -6818,7 +6818,7 @@ AbstractFunctionDecl::getObjCSelector(DeclName preferredName,
68186818
llvm_unreachable("Unknown subclass of AbstractFunctionDecl");
68196819
}
68206820

6821-
auto argNames = getFullName().getArgumentNames();
6821+
auto argNames = getName().getArgumentNames();
68226822

68236823
// Use the preferred name if specified
68246824
if (preferredName) {
@@ -6974,7 +6974,7 @@ ParamDecl *AbstractFunctionDecl::getImplicitSelfDecl(bool createIfNeeded) {
69746974

69756975
void AbstractFunctionDecl::setParameters(ParameterList *BodyParams) {
69766976
#ifndef NDEBUG
6977-
auto Name = getFullName();
6977+
const auto Name = getName();
69786978
if (!isa<DestructorDecl>(this))
69796979
assert((!Name || !Name.isSimpleName()) && "Must have a compound name");
69806980
assert(!Name || (Name.getArgumentNames().size() == BodyParams->size()));
@@ -7360,8 +7360,8 @@ ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
73607360

73617361
bool ConstructorDecl::isObjCZeroParameterWithLongSelector() const {
73627362
// The initializer must have a single, non-empty argument name.
7363-
if (getFullName().getArgumentNames().size() != 1 ||
7364-
getFullName().getArgumentNames()[0].empty())
7363+
if (getName().getArgumentNames().size() != 1 ||
7364+
getName().getArgumentNames()[0].empty())
73657365
return false;
73667366

73677367
auto *params = getParameters();
@@ -7923,7 +7923,7 @@ struct DeclTraceFormatter : public UnifiedStatsReporter::TraceFormatter {
79237923
return;
79247924
const Decl *D = static_cast<const Decl *>(Entity);
79257925
if (auto const *VD = dyn_cast<const ValueDecl>(D)) {
7926-
VD->getFullName().print(OS, false);
7926+
VD->getName().print(OS, false);
79277927
} else {
79287928
OS << "<"
79297929
<< Decl::getDescriptiveKindName(D->getDescriptiveKind())

lib/AST/DeclContext.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ void AccessScope::dump() const {
581581
if (auto *ext = dyn_cast<ExtensionDecl>(decl))
582582
llvm::errs() << ext->getExtendedNominal()->getName();
583583
else if (auto *named = dyn_cast<ValueDecl>(decl))
584-
llvm::errs() << named->getFullName();
584+
llvm::errs() << named->getName();
585585
else
586586
llvm::errs() << (const void *)decl;
587587

@@ -680,7 +680,7 @@ unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent,
680680
break;
681681
case DeclContextKind::AbstractFunctionDecl: {
682682
auto *AFD = cast<AbstractFunctionDecl>(this);
683-
OS << " name=" << AFD->getFullName();
683+
OS << " name=" << AFD->getName();
684684
if (AFD->hasInterfaceType())
685685
OS << " : " << AFD->getInterfaceType();
686686
else

lib/AST/DiagnosticEngine.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static void formatDiagnosticArgument(StringRef Modifier,
527527

528528
case DiagnosticArgumentKind::ValueDecl:
529529
Out << FormatOpts.OpeningQuotationMark;
530-
Arg.getAsValueDecl()->getFullName().printPretty(Out);
530+
Arg.getAsValueDecl()->getName().printPretty(Out);
531531
Out << FormatOpts.ClosingQuotationMark;
532532
break;
533533

@@ -556,7 +556,7 @@ static void formatDiagnosticArgument(StringRef Modifier,
556556
selfTy->print(OutNaming);
557557
OutNaming << '.';
558558
}
559-
namingDecl->getFullName().printPretty(OutNaming);
559+
namingDecl->getName().printPretty(OutNaming);
560560

561561
auto descriptiveKind = opaqueTypeDecl->getDescriptiveKind();
562562

lib/AST/DocComment.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ const ValueDecl *findDefaultProvidedDeclWithDocComment(const ValueDecl *VD,
417417

418418
SmallVector<ValueDecl *, 2> members;
419419
protocol->lookupQualified(const_cast<ProtocolDecl *>(protocol),
420-
DeclNameRef(VD->getFullName()),
420+
DeclNameRef(VD->getName()),
421421
NLOptions::NL_ProtocolMembers,
422422
members);
423423

lib/AST/Expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,7 @@ void InterpolatedStringLiteralExpr::forEachSegment(ASTContext &Ctx,
22332233
if (auto call = dyn_cast<CallExpr>(expr)) {
22342234
DeclName name;
22352235
if (auto fn = call->getCalledValue()) {
2236-
name = fn->getFullName();
2236+
name = fn->getName();
22372237
} else if (auto unresolvedDot =
22382238
dyn_cast<UnresolvedDotExpr>(call->getFn())) {
22392239
name = unresolvedDot->getName().getFullName();

lib/AST/FrontendSourceFileDepGraphFactory.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ struct SourceFileDeclFinder {
437437
auto *VD = dyn_cast<ValueDecl>(D);
438438
if (!VD || excludeIfPrivate(VD))
439439
continue;
440-
if (VD->getFullName().isOperator())
440+
if (VD->getName().isOperator())
441441
memberOperatorDecls.push_back(cast<FuncDecl>(D));
442442
else if (const auto *const NTD = dyn_cast<NominalTypeDecl>(D))
443443
findNominalsAndOperatorsIn(NTD);

lib/AST/GenericSignatureBuilder.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -3940,7 +3940,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
39403940
if (genReq->getGenericParams())
39413941
continue;
39423942

3943-
inheritedTypeDecls[typeReq->getFullName()].push_back(typeReq);
3943+
inheritedTypeDecls[typeReq->getName()].push_back(typeReq);
39443944
}
39453945
}
39463946
return TypeWalker::Action::Continue;
@@ -3967,7 +3967,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
39673967
llvm::raw_string_ostream out(result);
39683968
out << start;
39693969
interleave(assocType->getInherited(), [&](TypeLoc inheritedType) {
3970-
out << assocType->getFullName() << ": ";
3970+
out << assocType->getName() << ": ";
39713971
if (auto inheritedTypeRepr = inheritedType.getTypeRepr())
39723972
inheritedTypeRepr->print(out);
39733973
else
@@ -3994,7 +3994,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
39943994
{
39953995
llvm::raw_string_ostream out(result);
39963996
out << start;
3997-
out << type->getFullName() << " == ";
3997+
out << type->getName() << " == ";
39983998
if (auto typealias = dyn_cast<TypeAliasDecl>(type)) {
39993999
if (auto underlyingTypeRepr = typealias->getUnderlyingTypeRepr())
40004000
underlyingTypeRepr->print(out);
@@ -4053,7 +4053,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
40534053

40544054
// Check whether we inherited any types with the same name.
40554055
auto knownInherited =
4056-
inheritedTypeDecls.find(assocTypeDecl->getFullName());
4056+
inheritedTypeDecls.find(assocTypeDecl->getName());
40574057
if (knownInherited == inheritedTypeDecls.end()) continue;
40584058

40594059
bool shouldWarnAboutRedeclaration =
@@ -4074,15 +4074,15 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
40744074
auto fixItWhere = getProtocolWhereLoc();
40754075
Diags.diagnose(assocTypeDecl,
40764076
diag::inherited_associated_type_redecl,
4077-
assocTypeDecl->getFullName(),
4077+
assocTypeDecl->getName(),
40784078
inheritedFromProto->getDeclaredInterfaceType())
40794079
.fixItInsertAfter(
40804080
fixItWhere.Loc,
40814081
getAssociatedTypeReqs(assocTypeDecl, fixItWhere.Item))
40824082
.fixItRemove(assocTypeDecl->getSourceRange());
40834083

40844084
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
4085-
inheritedAssocTypeDecl->getFullName());
4085+
inheritedAssocTypeDecl->getName());
40864086

40874087
shouldWarnAboutRedeclaration = false;
40884088
}
@@ -4097,7 +4097,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
40974097
inheritedType->getDeclContext()->getSelfNominalTypeDecl();
40984098
Diags.diagnose(assocTypeDecl,
40994099
diag::associated_type_override_typealias,
4100-
assocTypeDecl->getFullName(),
4100+
assocTypeDecl->getName(),
41014101
inheritedOwningDecl->getDescriptiveKind(),
41024102
inheritedOwningDecl->getDeclaredInterfaceType());
41034103
}
@@ -4157,7 +4157,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
41574157
getConcreteTypeReq(type, fixItWhere.Item))
41584158
.fixItRemove(type->getSourceRange());
41594159
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
4160-
inheritedAssocTypeDecl->getFullName());
4160+
inheritedAssocTypeDecl->getName());
41614161

41624162
shouldWarnAboutRedeclaration = false;
41634163
}

0 commit comments

Comments
 (0)