Skip to content

Commit b4c7a7e

Browse files
authored
Merge pull request swiftlang#31224 from AnthonyLatsis/rename-getfullname-2
AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl
2 parents 0f892b6 + 7425202 commit b4c7a7e

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

Lines changed: 5 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 9 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ static Type mapSignatureFunctionType(ASTContext &ctx, Type type,
27772777
OverloadSignature ValueDecl::getOverloadSignature() const {
27782778
OverloadSignature signature;
27792779

2780-
signature.Name = getFullName();
2780+
signature.Name = getName();
27812781
signature.InProtocolExtension
27822782
= static_cast<bool>(getDeclContext()->getExtendedProtocolDecl());
27832783
signature.IsInstanceMember = isInstanceMember();
@@ -6649,8 +6649,8 @@ SourceRange SubscriptDecl::getSignatureSourceRange() const {
66496649
}
66506650

66516651
DeclName AbstractFunctionDecl::getEffectiveFullName() const {
6652-
if (getFullName())
6653-
return getFullName();
6652+
if (getName())
6653+
return getName();
66546654

66556655
if (auto accessor = dyn_cast<AccessorDecl>(this)) {
66566656
auto &ctx = getASTContext();
@@ -6663,7 +6663,7 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
66636663
case AccessorKind::Get:
66646664
case AccessorKind::Read:
66656665
case AccessorKind::Modify:
6666-
return subscript ? subscript->getFullName()
6666+
return subscript ? subscript->getName()
66676667
: DeclName(ctx, storage->getBaseName(),
66686668
ArrayRef<Identifier>());
66696669

@@ -6675,8 +6675,8 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
66756675
argNames.push_back(Identifier());
66766676
// The subscript index parameters.
66776677
if (subscript) {
6678-
argNames.append(subscript->getFullName().getArgumentNames().begin(),
6679-
subscript->getFullName().getArgumentNames().end());
6678+
argNames.append(subscript->getName().getArgumentNames().begin(),
6679+
subscript->getName().getArgumentNames().end());
66806680
}
66816681
return DeclName(ctx, storage->getBaseName(), argNames);
66826682
}
@@ -6836,7 +6836,7 @@ AbstractFunctionDecl::getObjCSelector(DeclName preferredName,
68366836
llvm_unreachable("Unknown subclass of AbstractFunctionDecl");
68376837
}
68386838

6839-
auto argNames = getFullName().getArgumentNames();
6839+
auto argNames = getName().getArgumentNames();
68406840

68416841
// Use the preferred name if specified
68426842
if (preferredName) {
@@ -6992,7 +6992,7 @@ ParamDecl *AbstractFunctionDecl::getImplicitSelfDecl(bool createIfNeeded) {
69926992

69936993
void AbstractFunctionDecl::setParameters(ParameterList *BodyParams) {
69946994
#ifndef NDEBUG
6995-
auto Name = getFullName();
6995+
const auto Name = getName();
69966996
if (!isa<DestructorDecl>(this))
69976997
assert((!Name || !Name.isSimpleName()) && "Must have a compound name");
69986998
assert(!Name || (Name.getArgumentNames().size() == BodyParams->size()));
@@ -7378,8 +7378,8 @@ ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
73787378

73797379
bool ConstructorDecl::isObjCZeroParameterWithLongSelector() const {
73807380
// The initializer must have a single, non-empty argument name.
7381-
if (getFullName().getArgumentNames().size() != 1 ||
7382-
getFullName().getArgumentNames()[0].empty())
7381+
if (getName().getArgumentNames().size() != 1 ||
7382+
getName().getArgumentNames()[0].empty())
73837383
return false;
73847384

73857385
auto *params = getParameters();
@@ -7941,7 +7941,7 @@ struct DeclTraceFormatter : public UnifiedStatsReporter::TraceFormatter {
79417941
return;
79427942
const Decl *D = static_cast<const Decl *>(Entity);
79437943
if (auto const *VD = dyn_cast<const ValueDecl>(D)) {
7944-
VD->getFullName().print(OS, false);
7944+
VD->getName().print(OS, false);
79457945
} else {
79467946
OS << "<"
79477947
<< Decl::getDescriptiveKindName(D->getDescriptiveKind())

lib/AST/DeclContext.cpp

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)