Skip to content

Commit 0bd0a29

Browse files
committed
[5.3] AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl
1 parent 55f8a20 commit 0bd0a29

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

@@ -4946,7 +4944,6 @@ class VarDecl : public AbstractStorageDecl {
49464944

49474945
/// Returns the string for the base name, or "_" if this is unnamed.
49484946
StringRef getNameStr() const {
4949-
assert(!getFullName().isSpecial() && "Cannot get string for special names");
49504947
return hasName() ? getBaseIdentifier().str() : "_";
49514948
}
49524949

@@ -5921,7 +5918,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
59215918

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

@@ -6621,7 +6618,7 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
66216618

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

@@ -7374,7 +7371,7 @@ class MissingMemberDecl : public Decl {
73747371
return new (ctx) MissingMemberDecl(DC, name, numVTableEntries, hasStorage);
73757372
}
73767373

7377-
DeclName getFullName() const {
7374+
DeclName getName() const {
73787375
return Name;
73797376
}
73807377

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 << '\'';
@@ -1106,7 +1106,7 @@ namespace {
11061106
void visitAccessorDecl(AccessorDecl *AD) {
11071107
printCommonFD(AD, "accessor_decl");
11081108
OS << " " << getAccessorKindString(AD->getAccessorKind());
1109-
OS << "_for=" << AD->getStorage()->getFullName();
1109+
OS << "_for=" << AD->getStorage()->getName();
11101110
printAbstractFunctionDecl(AD);
11111111
PrintWithColorRAII(OS, ParenthesisColor) << ')';
11121112
}
@@ -1269,7 +1269,7 @@ namespace {
12691269
void visitMissingMemberDecl(MissingMemberDecl *MMD) {
12701270
printCommon(MMD, "missing_member_decl ");
12711271
PrintWithColorRAII(OS, IdentifierColor)
1272-
<< '\"' << MMD->getFullName() << '\"';
1272+
<< '\"' << MMD->getName() << '\"';
12731273
PrintWithColorRAII(OS, ParenthesisColor) << ')';
12741274
}
12751275
};
@@ -1368,15 +1368,15 @@ void swift::printContext(raw_ostream &os, DeclContext *dc) {
13681368
break;
13691369

13701370
case DeclContextKind::AbstractFunctionDecl:
1371-
printName(os, cast<AbstractFunctionDecl>(dc)->getFullName());
1371+
printName(os, cast<AbstractFunctionDecl>(dc)->getName());
13721372
break;
13731373

13741374
case DeclContextKind::SubscriptDecl:
1375-
printName(os, cast<SubscriptDecl>(dc)->getFullName());
1375+
printName(os, cast<SubscriptDecl>(dc)->getName());
13761376
break;
13771377

13781378
case DeclContextKind::EnumElementDecl:
1379-
printName(os, cast<EnumElementDecl>(dc)->getFullName());
1379+
printName(os, cast<EnumElementDecl>(dc)->getName());
13801380
break;
13811381
}
13821382
}
@@ -1394,7 +1394,7 @@ void ValueDecl::dumpRef(raw_ostream &os) const {
13941394
os << ".";
13951395

13961396
// Print name.
1397-
getFullName().printPretty(os);
1397+
getName().printPretty(os);
13981398

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

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3266,7 +3266,7 @@ void PrintAST::visitModuleDecl(ModuleDecl *decl) { }
32663266

32673267
void PrintAST::visitMissingMemberDecl(MissingMemberDecl *decl) {
32683268
Printer << "/* placeholder for ";
3269-
recordDeclLoc(decl, [&]{ Printer << decl->getFullName(); });
3269+
recordDeclLoc(decl, [&]{ Printer << decl->getName(); });
32703270
unsigned numVTableEntries = decl->getNumberOfVTableEntries();
32713271
if (numVTableEntries > 0)
32723272
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
@@ -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

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)