Skip to content

AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl #31224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2503,8 +2503,7 @@ class ValueDecl : public Decl {
bool isOperator() const { return Name.isOperator(); }

/// Retrieve the full name of the declaration.
/// TODO: Rename to getName?
DeclName getFullName() const { return Name; }
DeclName getName() const { return Name; }
void setName(DeclName name) { Name = name; }

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

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

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

Expand Down Expand Up @@ -4950,7 +4948,6 @@ class VarDecl : public AbstractStorageDecl {

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

Expand Down Expand Up @@ -5925,7 +5922,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {

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

Expand Down Expand Up @@ -6625,7 +6622,7 @@ class EnumElementDecl : public DeclContext, public ValueDecl {

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

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

DeclName getFullName() const {
DeclName getName() const {
return Name;
}

Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/NameLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class NamedDeclConsumer : public VisibleDeclConsumer {
// to avoid circular validation.
if (isTypeLookup && !isa<TypeDecl>(VD))
return;
if (VD->getFullName().matchesRef(name.getFullName()))
if (VD->getName().matchesRef(name.getFullName()))
results.push_back(LookupResultEntry(VD));
}
};
Expand Down
18 changes: 9 additions & 9 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@ namespace {
}

void printDeclName(const ValueDecl *D) {
if (D->getFullName()) {
if (D->getName()) {
PrintWithColorRAII(OS, IdentifierColor)
<< '\"' << D->getFullName() << '\"';
<< '\"' << D->getName() << '\"';
} else {
PrintWithColorRAII(OS, IdentifierColor)
<< "'anonname=" << (const void*)D << '\'';
Expand Down Expand Up @@ -1105,7 +1105,7 @@ namespace {
void visitAccessorDecl(AccessorDecl *AD) {
printCommonFD(AD, "accessor_decl");
OS << " " << getAccessorKindString(AD->getAccessorKind());
OS << "_for=" << AD->getStorage()->getFullName();
OS << "_for=" << AD->getStorage()->getName();
printAbstractFunctionDecl(AD);
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}
Expand Down Expand Up @@ -1268,7 +1268,7 @@ namespace {
void visitMissingMemberDecl(MissingMemberDecl *MMD) {
printCommon(MMD, "missing_member_decl ");
PrintWithColorRAII(OS, IdentifierColor)
<< '\"' << MMD->getFullName() << '\"';
<< '\"' << MMD->getName() << '\"';
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}
};
Expand Down Expand Up @@ -1367,15 +1367,15 @@ void swift::printContext(raw_ostream &os, DeclContext *dc) {
break;

case DeclContextKind::AbstractFunctionDecl:
printName(os, cast<AbstractFunctionDecl>(dc)->getFullName());
printName(os, cast<AbstractFunctionDecl>(dc)->getName());
break;

case DeclContextKind::SubscriptDecl:
printName(os, cast<SubscriptDecl>(dc)->getFullName());
printName(os, cast<SubscriptDecl>(dc)->getName());
break;

case DeclContextKind::EnumElementDecl:
printName(os, cast<EnumElementDecl>(dc)->getFullName());
printName(os, cast<EnumElementDecl>(dc)->getName());
break;
}
}
Expand All @@ -1393,7 +1393,7 @@ void ValueDecl::dumpRef(raw_ostream &os) const {
os << ".";

// Print name.
getFullName().printPretty(os);
getName().printPretty(os);

// Print location.
auto &srcMgr = getASTContext().SourceMgr;
Expand Down Expand Up @@ -3171,7 +3171,7 @@ static void dumpProtocolConformanceRec(
out << '\n';
out.indent(indent + 2);
PrintWithColorRAII(out, ParenthesisColor) << '(';
out << "value req=" << req->getFullName() << " witness=";
out << "value req=" << req->getName() << " witness=";
if (!witness) {
out << "(none)";
} else if (witness.getDecl() == req) {
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ void PrintAST::visitModuleDecl(ModuleDecl *decl) { }

void PrintAST::visitMissingMemberDecl(MissingMemberDecl *decl) {
Printer << "/* placeholder for ";
recordDeclLoc(decl, [&]{ Printer << decl->getFullName(); });
recordDeclLoc(decl, [&]{ Printer << decl->getName(); });
unsigned numVTableEntries = decl->getNumberOfVTableEntries();
if (numVTableEntries > 0)
Printer << " (vtable entries: " << numVTableEntries << ")";
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/ASTScopePrinting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void ASTScopeImpl::dumpOneScopeMapLocation(
llvm::errs() << "Local bindings: ";
llvm::interleave(
gatherer.getDecls().begin(), gatherer.getDecls().end(),
[&](ValueDecl *value) { llvm::errs() << value->getFullName(); },
[&](ValueDecl *value) { llvm::errs() << value->getName(); },
[&]() { llvm::errs() << " "; });
llvm::errs() << "\n";
}
Expand Down Expand Up @@ -169,7 +169,7 @@ void GenericParamScope::printSpecifics(llvm::raw_ostream &out) const {
}

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

void AbstractPatternEntryScope::printSpecifics(llvm::raw_ostream &out) const {
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2814,8 +2814,8 @@ class Verifier : public ASTWalker {

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

if (checkParamNames &&
Expand Down
22 changes: 11 additions & 11 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,7 @@ static Type mapSignatureFunctionType(ASTContext &ctx, Type type,
OverloadSignature ValueDecl::getOverloadSignature() const {
OverloadSignature signature;

signature.Name = getFullName();
signature.Name = getName();
signature.InProtocolExtension
= static_cast<bool>(getDeclContext()->getExtendedProtocolDecl());
signature.IsInstanceMember = isInstanceMember();
Expand Down Expand Up @@ -6631,8 +6631,8 @@ SourceRange SubscriptDecl::getSignatureSourceRange() const {
}

DeclName AbstractFunctionDecl::getEffectiveFullName() const {
if (getFullName())
return getFullName();
if (getName())
return getName();

if (auto accessor = dyn_cast<AccessorDecl>(this)) {
auto &ctx = getASTContext();
Expand All @@ -6645,7 +6645,7 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
case AccessorKind::Get:
case AccessorKind::Read:
case AccessorKind::Modify:
return subscript ? subscript->getFullName()
return subscript ? subscript->getName()
: DeclName(ctx, storage->getBaseName(),
ArrayRef<Identifier>());

Expand All @@ -6657,8 +6657,8 @@ DeclName AbstractFunctionDecl::getEffectiveFullName() const {
argNames.push_back(Identifier());
// The subscript index parameters.
if (subscript) {
argNames.append(subscript->getFullName().getArgumentNames().begin(),
subscript->getFullName().getArgumentNames().end());
argNames.append(subscript->getName().getArgumentNames().begin(),
subscript->getName().getArgumentNames().end());
}
return DeclName(ctx, storage->getBaseName(), argNames);
}
Expand Down Expand Up @@ -6818,7 +6818,7 @@ AbstractFunctionDecl::getObjCSelector(DeclName preferredName,
llvm_unreachable("Unknown subclass of AbstractFunctionDecl");
}

auto argNames = getFullName().getArgumentNames();
auto argNames = getName().getArgumentNames();

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

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

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

auto *params = getParameters();
Expand Down Expand Up @@ -7923,7 +7923,7 @@ struct DeclTraceFormatter : public UnifiedStatsReporter::TraceFormatter {
return;
const Decl *D = static_cast<const Decl *>(Entity);
if (auto const *VD = dyn_cast<const ValueDecl>(D)) {
VD->getFullName().print(OS, false);
VD->getName().print(OS, false);
} else {
OS << "<"
<< Decl::getDescriptiveKindName(D->getDescriptiveKind())
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/DeclContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ void AccessScope::dump() const {
if (auto *ext = dyn_cast<ExtensionDecl>(decl))
llvm::errs() << ext->getExtendedNominal()->getName();
else if (auto *named = dyn_cast<ValueDecl>(decl))
llvm::errs() << named->getFullName();
llvm::errs() << named->getName();
else
llvm::errs() << (const void *)decl;

Expand Down Expand Up @@ -680,7 +680,7 @@ unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent,
break;
case DeclContextKind::AbstractFunctionDecl: {
auto *AFD = cast<AbstractFunctionDecl>(this);
OS << " name=" << AFD->getFullName();
OS << " name=" << AFD->getName();
if (AFD->hasInterfaceType())
OS << " : " << AFD->getInterfaceType();
else
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static void formatDiagnosticArgument(StringRef Modifier,

case DiagnosticArgumentKind::ValueDecl:
Out << FormatOpts.OpeningQuotationMark;
Arg.getAsValueDecl()->getFullName().printPretty(Out);
Arg.getAsValueDecl()->getName().printPretty(Out);
Out << FormatOpts.ClosingQuotationMark;
break;

Expand Down Expand Up @@ -556,7 +556,7 @@ static void formatDiagnosticArgument(StringRef Modifier,
selfTy->print(OutNaming);
OutNaming << '.';
}
namingDecl->getFullName().printPretty(OutNaming);
namingDecl->getName().printPretty(OutNaming);

auto descriptiveKind = opaqueTypeDecl->getDescriptiveKind();

Expand Down
2 changes: 1 addition & 1 deletion lib/AST/DocComment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const ValueDecl *findDefaultProvidedDeclWithDocComment(const ValueDecl *VD,

SmallVector<ValueDecl *, 2> members;
protocol->lookupQualified(const_cast<ProtocolDecl *>(protocol),
DeclNameRef(VD->getFullName()),
DeclNameRef(VD->getName()),
NLOptions::NL_ProtocolMembers,
members);

Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,7 @@ void InterpolatedStringLiteralExpr::forEachSegment(ASTContext &Ctx,
if (auto call = dyn_cast<CallExpr>(expr)) {
DeclName name;
if (auto fn = call->getCalledValue()) {
name = fn->getFullName();
name = fn->getName();
} else if (auto unresolvedDot =
dyn_cast<UnresolvedDotExpr>(call->getFn())) {
name = unresolvedDot->getName().getFullName();
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/FrontendSourceFileDepGraphFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ struct SourceFileDeclFinder {
auto *VD = dyn_cast<ValueDecl>(D);
if (!VD || excludeIfPrivate(VD))
continue;
if (VD->getFullName().isOperator())
if (VD->getName().isOperator())
memberOperatorDecls.push_back(cast<FuncDecl>(D));
else if (const auto *const NTD = dyn_cast<NominalTypeDecl>(D))
findNominalsAndOperatorsIn(NTD);
Expand Down
16 changes: 8 additions & 8 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3940,7 +3940,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
if (genReq->getGenericParams())
continue;

inheritedTypeDecls[typeReq->getFullName()].push_back(typeReq);
inheritedTypeDecls[typeReq->getName()].push_back(typeReq);
}
}
return TypeWalker::Action::Continue;
Expand All @@ -3967,7 +3967,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
llvm::raw_string_ostream out(result);
out << start;
interleave(assocType->getInherited(), [&](TypeLoc inheritedType) {
out << assocType->getFullName() << ": ";
out << assocType->getName() << ": ";
if (auto inheritedTypeRepr = inheritedType.getTypeRepr())
inheritedTypeRepr->print(out);
else
Expand All @@ -3994,7 +3994,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
{
llvm::raw_string_ostream out(result);
out << start;
out << type->getFullName() << " == ";
out << type->getName() << " == ";
if (auto typealias = dyn_cast<TypeAliasDecl>(type)) {
if (auto underlyingTypeRepr = typealias->getUnderlyingTypeRepr())
underlyingTypeRepr->print(out);
Expand Down Expand Up @@ -4053,7 +4053,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(

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

bool shouldWarnAboutRedeclaration =
Expand All @@ -4074,15 +4074,15 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
auto fixItWhere = getProtocolWhereLoc();
Diags.diagnose(assocTypeDecl,
diag::inherited_associated_type_redecl,
assocTypeDecl->getFullName(),
assocTypeDecl->getName(),
inheritedFromProto->getDeclaredInterfaceType())
.fixItInsertAfter(
fixItWhere.Loc,
getAssociatedTypeReqs(assocTypeDecl, fixItWhere.Item))
.fixItRemove(assocTypeDecl->getSourceRange());

Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
inheritedAssocTypeDecl->getFullName());
inheritedAssocTypeDecl->getName());

shouldWarnAboutRedeclaration = false;
}
Expand All @@ -4097,7 +4097,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
inheritedType->getDeclContext()->getSelfNominalTypeDecl();
Diags.diagnose(assocTypeDecl,
diag::associated_type_override_typealias,
assocTypeDecl->getFullName(),
assocTypeDecl->getName(),
inheritedOwningDecl->getDescriptiveKind(),
inheritedOwningDecl->getDeclaredInterfaceType());
}
Expand Down Expand Up @@ -4157,7 +4157,7 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
getConcreteTypeReq(type, fixItWhere.Item))
.fixItRemove(type->getSourceRange());
Diags.diagnose(inheritedAssocTypeDecl, diag::decl_declared_here,
inheritedAssocTypeDecl->getFullName());
inheritedAssocTypeDecl->getName());

shouldWarnAboutRedeclaration = false;
}
Expand Down
Loading