From d0ae3ee580877eb19081a5063e2978a28ed76361 Mon Sep 17 00:00:00 2001 From: Anthony Latsis Date: Tue, 24 Mar 2020 09:19:32 +0300 Subject: [PATCH 1/2] [AST] Replace FuncDecl::getName & EnumElementDecl::getName with ValueDecl::getBaseIdentifier --- include/swift/AST/Decl.h | 8 ++++---- lib/AST/ASTDumper.cpp | 2 +- lib/AST/ASTPrinter.cpp | 5 +++-- lib/AST/Decl.cpp | 7 ++++--- lib/AST/FrontendSourceFileDepGraphFactory.cpp | 12 ++++-------- lib/AST/SwiftNameTranslation.cpp | 2 +- lib/FrontendTool/ReferenceDependencies.cpp | 2 +- lib/IDE/CodeCompletion.cpp | 8 ++++---- lib/IDE/Refactoring.cpp | 5 +++-- lib/IDE/SyntaxModel.cpp | 5 +++-- lib/IRGen/GenEnum.cpp | 2 +- lib/IRGen/IRGenDebugInfo.cpp | 6 +++--- lib/Index/IndexSymbol.cpp | 2 +- lib/PrintAsObjC/DeclAndTypePrinter.cpp | 2 +- lib/PrintAsObjC/ModuleContentsWriter.cpp | 2 +- lib/SILGen/SILGenBuiltin.cpp | 4 ++-- .../Mandatory/DefiniteInitialization.cpp | 7 ++++--- lib/SILOptimizer/Mandatory/YieldOnceCheck.cpp | 2 +- lib/Sema/CSApply.cpp | 2 +- lib/Sema/CSDiagnostics.cpp | 4 ++-- lib/Sema/DerivedConformanceCodable.cpp | 7 ++++--- lib/Sema/DerivedConformanceEquatableHashable.cpp | 4 ++-- lib/Sema/TypeCheckAttr.cpp | 6 +++--- lib/Sema/TypeCheckConstraints.cpp | 2 +- lib/Sema/TypeCheckSwitchStmt.cpp | 2 +- 25 files changed, 56 insertions(+), 54 deletions(-) diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index c27525c366f63..f0f749969bc73 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -2496,6 +2496,10 @@ class ValueDecl : public Decl { /// names. DeclBaseName getBaseName() const { return Name.getBaseName(); } + Identifier getBaseIdentifier() const { + return getFullName().getBaseIdentifier(); + } + /// Generates a DeclNameRef referring to this declaration with as much /// specificity as possible. DeclNameRef createNameRef() const { @@ -6239,8 +6243,6 @@ class FuncDecl : public AbstractFunctionDecl { TypeLoc FnRetType, DeclContext *Parent, ClangNode ClangN = ClangNode()); - Identifier getName() const { return getFullName().getBaseIdentifier(); } - bool isStatic() const; /// \returns the way 'static'/'class' was spelled in the source. @@ -6583,8 +6585,6 @@ class EnumElementDecl : public DeclContext, public ValueDecl { LiteralExpr *RawValueExpr, DeclContext *DC); - Identifier getName() const { return getFullName().getBaseIdentifier(); } - /// Returns the string for the base name, or "_" if this is unnamed. StringRef getNameStr() const { assert(!getFullName().isSpecial() && "Cannot get string for special names"); diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 403b4194c1085..cf6331eaf0193 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -2613,7 +2613,7 @@ class PrintExpr : public ExprVisitor { } void visitEnumIsCaseExpr(EnumIsCaseExpr *E) { printCommon(E, "enum_is_case_expr") << ' ' << - E->getEnumElement()->getName() << "\n"; + E->getEnumElement()->getBaseIdentifier() << "\n"; printRec(E->getSubExpr()); PrintWithColorRAII(OS, ParenthesisColor) << ')'; } diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 0abdddb47b084..81bccf8538024 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -2876,7 +2876,7 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) { if (!decl->hasName()) { Printer << ""; } else { - Printer.printName(decl->getName(), + Printer.printName(decl->getBaseIdentifier(), getTypeMemberPrintNameContext(decl)); if (decl->isOperator()) Printer << " "; @@ -2949,7 +2949,8 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) { void PrintAST::printEnumElement(EnumElementDecl *elt) { recordDeclLoc(elt, [&]{ - Printer.printName(elt->getName(), getTypeMemberPrintNameContext(elt)); + Printer.printName(elt->getBaseIdentifier(), + getTypeMemberPrintNameContext(elt)); }); if (auto *PL = elt->getParameterList()) { diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 9cd85da7c5498..658eef9ff46f8 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -6833,7 +6833,7 @@ AbstractFunctionDecl::getObjCSelector(DeclName preferredName, return destructor->getObjCSelector(); } else if (auto func = dyn_cast(this)) { // Otherwise cast this to be able to access getName() - baseNameStr = func->getName().str(); + baseNameStr = func->getBaseIdentifier().str(); } else if (isa(this)) { baseNameStr = "init"; } else { @@ -7341,7 +7341,8 @@ SelfAccessKind FuncDecl::getSelfAccessKind() const { } bool FuncDecl::isCallAsFunctionMethod() const { - return getName() == getASTContext().Id_callAsFunction && isInstanceMember(); + return getBaseIdentifier() == getASTContext().Id_callAsFunction && + isInstanceMember(); } ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc, @@ -7838,7 +7839,7 @@ PrecedenceGroupDecl *InfixOperatorDecl::getPrecedenceGroup() const { } bool FuncDecl::isDeferBody() const { - return getName() == getASTContext().getIdentifier("$defer"); + return getBaseIdentifier() == getASTContext().getIdentifier("$defer"); } bool FuncDecl::isPotentialIBActionTarget() const { diff --git a/lib/AST/FrontendSourceFileDepGraphFactory.cpp b/lib/AST/FrontendSourceFileDepGraphFactory.cpp index 51daa41e2e20b..aa2544995e441 100644 --- a/lib/AST/FrontendSourceFileDepGraphFactory.cpp +++ b/lib/AST/FrontendSourceFileDepGraphFactory.cpp @@ -59,10 +59,6 @@ template static std::string getBaseName(const DeclT *decl) { return decl->getBaseName().userFacingName().str(); } -template static std::string getName(const DeclT *decl) { - return DeclBaseName(decl->getName()).userFacingName().str(); -} - static std::string mangleTypeAsContext(const NominalTypeDecl *NTD) { Mangle::ASTMangler Mangler; return !NTD ? "" : Mangler.mangleTypeAsContextUSR(NTD); @@ -188,22 +184,22 @@ std::string DependencyKey::computeNameForProvidedEntity( const PrecedenceGroupDecl *D) { - return ::getName(D); + return D->getName().str().str(); } template <> std::string DependencyKey::computeNameForProvidedEntity< NodeKind::topLevel, FuncDecl const *>(const FuncDecl *D) { - return ::getName(D); + return getBaseName(D); } template <> std::string DependencyKey::computeNameForProvidedEntity< NodeKind::topLevel, OperatorDecl const *>(const OperatorDecl *D) { - return ::getName(D); + return D->getName().str().str(); } template <> std::string DependencyKey::computeNameForProvidedEntity< NodeKind::topLevel, NominalTypeDecl const *>(const NominalTypeDecl *D) { - return ::getName(D); + return D->getName().str().str(); } template <> std::string DependencyKey::computeNameForProvidedEntity< diff --git a/lib/AST/SwiftNameTranslation.cpp b/lib/AST/SwiftNameTranslation.cpp index 53109c7192277..abe9443e0ebb8 100644 --- a/lib/AST/SwiftNameTranslation.cpp +++ b/lib/AST/SwiftNameTranslation.cpp @@ -90,7 +90,7 @@ printSwiftEnumElemNameInObjC(const EnumElementDecl *EL, llvm::raw_ostream &OS, } OS << getNameForObjC(EL->getDeclContext()->getSelfEnumDecl()); if (PreferredName.empty()) - ElemName = EL->getName().str(); + ElemName = EL->getBaseIdentifier().str(); else ElemName = PreferredName.str(); diff --git a/lib/FrontendTool/ReferenceDependencies.cpp b/lib/FrontendTool/ReferenceDependencies.cpp index fd1b0fd46f8d5..2ba6324c6b7cd 100644 --- a/lib/FrontendTool/ReferenceDependencies.cpp +++ b/lib/FrontendTool/ReferenceDependencies.cpp @@ -254,7 +254,7 @@ ProvidesEmitter::emitTopLevelNames() const { for (const Decl *D : SF->getTopLevelDecls()) emitTopLevelDecl(D, cpd); for (auto *operatorFunction : cpd.memberOperatorDecls) - out << "- \"" << escape(operatorFunction->getName()) << "\"\n"; + out << "- \"" << escape(operatorFunction->getBaseIdentifier()) << "\"\n"; return cpd; } diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 5a9b36fc86a6c..12c07d7e74068 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -2177,7 +2177,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer { VD->shouldHideFromEditor()) return; - Identifier Name = VD->getName(); + const Identifier Name = VD->getName(); assert(!Name.empty() && "name should not be empty"); CommandWordsPairs Pairs; @@ -2576,11 +2576,11 @@ class CompletionLookup final : public swift::VisibleDeclConsumer { void addMethodCall(const FuncDecl *FD, DeclVisibilityKind Reason, DynamicLookupInfo dynamicLookupInfo) { - if (FD->getName().empty()) + if (FD->getBaseIdentifier().empty()) return; foundFunction(FD); - Identifier Name = FD->getName(); + const Identifier Name = FD->getBaseIdentifier(); assert(!Name.empty() && "name should not be empty"); Type FunctionType = getTypeOfMember(FD, dynamicLookupInfo); @@ -2944,7 +2944,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer { setAssociatedDecl(EED, Builder); setClangDeclKeywords(EED, Pairs, Builder); addLeadingDot(Builder); - addValueBaseName(Builder, EED->getName()); + addValueBaseName(Builder, EED->getBaseIdentifier()); // Enum element is of function type; (Self.type) -> Self or // (Self.Type) -> (Args...) -> Self. diff --git a/lib/IDE/Refactoring.cpp b/lib/IDE/Refactoring.cpp index 511cfe684b789..36c9673b3342d 100644 --- a/lib/IDE/Refactoring.cpp +++ b/lib/IDE/Refactoring.cpp @@ -2278,7 +2278,7 @@ isApplicable(ResolvedRangeInfo Info, DiagnosticEngine &Diag) { } bool checkName(FuncDecl *FD) { - auto Name = FD->getName().str(); + const auto Name = FD->getBaseIdentifier().str(); return Name == "~=" || Name == "==" || Name == "__derived_enum_equals" @@ -2391,7 +2391,8 @@ bool RefactoringActionConvertToSwitchStmt::performChange() { bool isFunctionNameAllowed(BinaryExpr *E) { auto FunctionBody = dyn_cast(E->getFn())->getFn(); auto FunctionDeclaration = dyn_cast(FunctionBody)->getDecl(); - auto FunctionName = dyn_cast(FunctionDeclaration)->getName().str(); + const auto FunctionName = dyn_cast(FunctionDeclaration) + ->getBaseIdentifier().str(); return FunctionName == "~=" || FunctionName == "==" || FunctionName == "__derived_enum_equals" diff --git a/lib/IDE/SyntaxModel.cpp b/lib/IDE/SyntaxModel.cpp index bfd5df7c86141..3a2b1f3a0774e 100644 --- a/lib/IDE/SyntaxModel.cpp +++ b/lib/IDE/SyntaxModel.cpp @@ -1047,7 +1047,7 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) { // as members of the enum case decl. Walk them manually here so that they // end up as child nodes of enum case. for (auto *EnumElemD : EnumCaseD->getElements()) { - if (EnumElemD->getName().empty()) + if (EnumElemD->getBaseIdentifier().empty()) continue; SyntaxStructureNode SN; setDecl(SN, EnumElemD); @@ -1060,7 +1060,8 @@ bool ModelASTWalker::walkToDeclPre(Decl *D) { SN.NameRange = charSourceRangeFromSourceRange(SM, NameRange); } else { SN.NameRange = CharSourceRange(EnumElemD->getNameLoc(), - EnumElemD->getName().getLength()); + EnumElemD->getBaseIdentifier() + .getLength()); } if (auto *E = EnumElemD->getRawValueUnchecked()) { diff --git a/lib/IRGen/GenEnum.cpp b/lib/IRGen/GenEnum.cpp index e3ea83d7cef06..96f516f4c3b6a 100644 --- a/lib/IRGen/GenEnum.cpp +++ b/lib/IRGen/GenEnum.cpp @@ -6917,7 +6917,7 @@ const TypeInfo *TypeConverter::convertEnumType(TypeBase *key, CanType type, auto bitPattern = strategy->getBitPatternForNoPayloadElement(elt.decl); assert(bitPattern.size() == fixedTI->getFixedSize().getValueInBits()); LLVM_DEBUG(llvm::dbgs() << " no-payload case " - << elt.decl->getName().str() + << elt.decl->getBaseIdentifier().str() << ":\t"; displayBitMask(bitPattern)); diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index 263d6036fffac..60fd4579c0cbb 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -489,7 +489,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { } if (FD.hasName()) - return FD.getName().str(); + return FD.getBaseIdentifier().str(); return StringRef(); } @@ -947,8 +947,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { Alignment(1), true, false); } unsigned Offset = 0; - auto MTy = createMemberType(ElemDbgTy, ElemDecl->getName().str(), Offset, - Scope, File, Flags); + auto MTy = createMemberType(ElemDbgTy, ElemDecl->getBaseIdentifier().str(), + Offset, Scope, File, Flags); Elements.push_back(MTy); } return DBuilder.getOrCreateArray(Elements); diff --git a/lib/Index/IndexSymbol.cpp b/lib/Index/IndexSymbol.cpp index 6ca05d2fcb912..caa333508999a 100644 --- a/lib/Index/IndexSymbol.cpp +++ b/lib/Index/IndexSymbol.cpp @@ -75,7 +75,7 @@ static bool isUnitTest(const ValueDecl *D) { return false; // 6. ...and starts with "test". - if (FD->getName().str().startswith("test")) + if (FD->getBaseIdentifier().str().startswith("test")) return true; return false; diff --git a/lib/PrintAsObjC/DeclAndTypePrinter.cpp b/lib/PrintAsObjC/DeclAndTypePrinter.cpp index 924ebd545d862..0c993a69c182c 100644 --- a/lib/PrintAsObjC/DeclAndTypePrinter.cpp +++ b/lib/PrintAsObjC/DeclAndTypePrinter.cpp @@ -395,7 +395,7 @@ class DeclAndTypePrinter::Implementation // name. os << " "; if (printSwiftEnumElemNameInObjC(Elt, os)) { - os << " SWIFT_COMPILE_NAME(\"" << Elt->getName() << "\")"; + os << " SWIFT_COMPILE_NAME(\"" << Elt->getBaseIdentifier() << "\")"; } // Print the raw values, even the ones that we synthesize. diff --git a/lib/PrintAsObjC/ModuleContentsWriter.cpp b/lib/PrintAsObjC/ModuleContentsWriter.cpp index a1653028bfdc2..d850955c51e4b 100644 --- a/lib/PrintAsObjC/ModuleContentsWriter.cpp +++ b/lib/PrintAsObjC/ModuleContentsWriter.cpp @@ -443,7 +443,7 @@ class ModuleWriter { bool hasDomainCase = std::any_of(ED->getAllElements().begin(), ED->getAllElements().end(), [](const EnumElementDecl *elem) { - return elem->getName().str() == "Domain"; + return elem->getBaseIdentifier().str() == "Domain"; }); if (!hasDomainCase) { os << "static NSString * _Nonnull const " << getNameForObjC(ED) diff --git a/lib/SILGen/SILGenBuiltin.cpp b/lib/SILGen/SILGenBuiltin.cpp index 6062de8864e61..8ba39d4204adb 100644 --- a/lib/SILGen/SILGenBuiltin.cpp +++ b/lib/SILGen/SILGenBuiltin.cpp @@ -1154,7 +1154,7 @@ static ManagedValue emitBuiltinApplyDerivative( auto builtinDecl = cast(cast( cast(callExpr->getDirectCallee())->getRHS()) ->getDecl()); - auto builtinName = builtinDecl->getName().str(); + const auto builtinName = builtinDecl->getBaseIdentifier().str(); AutoDiffDerivativeFunctionKind kind; unsigned arity; bool throws; @@ -1172,7 +1172,7 @@ static ManagedValue emitBuiltinApplyTranspose( auto builtinDecl = cast(cast( cast(callExpr->getDirectCallee())->getRHS()) ->getDecl()); - auto builtinName = builtinDecl->getName().str(); + const auto builtinName = builtinDecl->getBaseIdentifier().str(); unsigned arity; bool throws; auto successfullyParsed = autodiff::getBuiltinApplyTransposeConfig( diff --git a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp index e5698a367e9cf..17d9be5a4854f 100644 --- a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp +++ b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp @@ -1203,11 +1203,12 @@ void LifetimeChecker::handleInOutUse(const DIMemoryUse &Use) { } else if (FD && FD->isOperator()) { diagnose(Module, Use.Inst->getLoc(), diag::mutating_method_called_on_immutable_value, - FD->getName(), /*operator*/ 1, StringRef(PropertyName)); + FD->getBaseIdentifier(), /*operator*/ 1, + StringRef(PropertyName)); } else if (FD && isSelfParameter) { diagnose(Module, Use.Inst->getLoc(), diag::mutating_method_called_on_immutable_value, - FD->getName(), /*method*/ 0, StringRef(PropertyName)); + FD->getBaseIdentifier(), /*method*/ 0, StringRef(PropertyName)); } else if (isAssignment) { diagnose(Module, Use.Inst->getLoc(), diag::assignment_to_immutable_value, StringRef(PropertyName)); @@ -1590,7 +1591,7 @@ bool LifetimeChecker::diagnoseMethodCall(const DIMemoryUse &Use, if (auto accessor = dyn_cast(Method)) Name = accessor->getStorage()->getBaseName(); else - Name = Method->getName(); + Name = Method->getBaseIdentifier(); // If this is a use of self before super.init was called, emit a diagnostic // about *that* instead of about individual properties not being diff --git a/lib/SILOptimizer/Mandatory/YieldOnceCheck.cpp b/lib/SILOptimizer/Mandatory/YieldOnceCheck.cpp index ca4ea8fc42623..c7877c087b928 100644 --- a/lib/SILOptimizer/Mandatory/YieldOnceCheck.cpp +++ b/lib/SILOptimizer/Mandatory/YieldOnceCheck.cpp @@ -465,7 +465,7 @@ class YieldOnceCheck : public SILFunctionTransform { diagnose(astCtx, enumCaseLoc, diag::case_doesnt_yield, OptionSome); } else { diagnose(astCtx, enumCaseLoc, diag::named_case_doesnt_yield, - enumElemDecl.get()->getName()); + enumElemDecl.get()->getBaseIdentifier()); } return; } diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 2d212b0c2f9f7..040fabff2992a 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -7056,7 +7056,7 @@ Expr *ExprRewriter::convertLiteralInPlace(Expr *literal, static bool isValidDynamicCallableMethod(FuncDecl *method, AnyFunctionType *methodType) { auto &ctx = method->getASTContext(); - if (method->getName() != ctx.Id_dynamicallyCall) + if (method->getBaseIdentifier() != ctx.Id_dynamicallyCall) return false; if (methodType->getParams().size() != 1) return false; diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index d850427e850a3..f7d45d7028979 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -4819,7 +4819,7 @@ bool ExtraneousReturnFailure::diagnoseAsError() { // because certain decls will have empty name (like setters). if (FD->getBodyResultTypeLoc().getLoc().isInvalid() && FD->getParameters()->getStartLoc().isValid() && - !FD->getName().empty()) { + !FD->getBaseIdentifier().empty()) { auto fixItLoc = Lexer::getLocForEndOfToken( getASTContext().SourceMgr, FD->getParameters()->getEndLoc()); emitDiagnostic(anchor->getLoc(), diag::add_return_type_note) @@ -5725,7 +5725,7 @@ bool ExtraneousCallFailure::diagnoseAsError() { if (auto *enumCase = dyn_cast(decl)) { auto diagnostic = emitDiagnostic( anchor->getLoc(), diag::unexpected_arguments_in_enum_case, - enumCase->getName()); + enumCase->getBaseIdentifier()); removeParensFixIt(diagnostic); return true; } diff --git a/lib/Sema/DerivedConformanceCodable.cpp b/lib/Sema/DerivedConformanceCodable.cpp index 9d5681d752522..6815d9e322899 100644 --- a/lib/Sema/DerivedConformanceCodable.cpp +++ b/lib/Sema/DerivedConformanceCodable.cpp @@ -154,10 +154,10 @@ static bool validateCodingKeysEnum(DerivedConformance &derived, bool propertiesAreValid = true; for (auto elt : codingKeysDecl->getAllElements()) { - auto it = properties.find(elt->getName()); + auto it = properties.find(elt->getBaseIdentifier()); if (it == properties.end()) { elt->diagnose(diag::codable_extraneous_codingkey_case_here, - elt->getName()); + elt->getBaseIdentifier()); // TODO: Investigate typo-correction here; perhaps the case name was // misspelled and we can provide a fix-it. propertiesAreValid = false; @@ -493,7 +493,8 @@ static std::tuple lookupVarDeclForCodingKeysCase(DeclContext *conformanceDC, EnumElementDecl *elt, NominalTypeDecl *targetDecl) { - for (auto decl : targetDecl->lookupDirect(DeclName(elt->getName()))) { + for (auto decl : targetDecl->lookupDirect( + DeclName(elt->getBaseIdentifier()))) { if (auto *vd = dyn_cast(decl)) { // If we found a property with an attached wrapper, retrieve the // backing property. diff --git a/lib/Sema/DerivedConformanceEquatableHashable.cpp b/lib/Sema/DerivedConformanceEquatableHashable.cpp index 29fc56be27542..e5449f714750e 100644 --- a/lib/Sema/DerivedConformanceEquatableHashable.cpp +++ b/lib/Sema/DerivedConformanceEquatableHashable.cpp @@ -785,8 +785,8 @@ deriveBodyHashable_enum_hasAssociatedValues_hashInto( payloadVars); auto pat = new (C) EnumElementPattern(TypeLoc::withoutLoc(enumType), SourceLoc(), DeclNameLoc(), - DeclNameRef(elt->getName()), elt, - payloadPattern); + DeclNameRef(elt->getBaseIdentifier()), + elt, payloadPattern); pat->setImplicit(); auto labelItem = CaseLabelItem(pat); diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 1bf0f5c292905..02f7a0d555b13 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -161,7 +161,7 @@ class AttributeChecker : public AttributeVisitor { // An indirect case should have a payload. if (!caseDecl->hasAssociatedValues()) diagnose(attr->getLocation(), diag::indirect_case_without_payload, - caseDecl->getName()); + caseDecl->getBaseIdentifier()); // If the enum is already indirect, its cases don't need to be. else if (caseDecl->getParentEnum()->getAttrs() .hasAttribute()) @@ -1562,9 +1562,9 @@ void AttributeChecker::checkOperatorAttribute(DeclAttribute *attr) { } // Reject attempts to define builtin operators. - if (isBuiltinOperator(FD->getName().str(), attr)) { + if (isBuiltinOperator(FD->getBaseIdentifier().str(), attr)) { diagnose(D->getStartLoc(), diag::redefining_builtin_operator, - attr->getAttrName(), FD->getName().str()); + attr->getAttrName(), FD->getBaseIdentifier().str()); attr->setInvalid(); return; } diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp index fe79350f15fa7..51a8347336c90 100644 --- a/lib/Sema/TypeCheckConstraints.cpp +++ b/lib/Sema/TypeCheckConstraints.cpp @@ -3834,7 +3834,7 @@ CheckedCastKind TypeChecker::typeCheckCheckedCast(Type fromType, if (auto FD = dyn_cast(DRE->getDecl())) { if (!FD->getResultInterfaceType()->isVoid()) { diags.diagnose(diagLoc, diag::downcast_to_unrelated_fixit, - FD->getName()) + FD->getBaseIdentifier()) .fixItInsertAfter(fromExpr->getEndLoc(), "()"); } } diff --git a/lib/Sema/TypeCheckSwitchStmt.cpp b/lib/Sema/TypeCheckSwitchStmt.cpp index 96ae079900674..970de01930052 100644 --- a/lib/Sema/TypeCheckSwitchStmt.cpp +++ b/lib/Sema/TypeCheckSwitchStmt.cpp @@ -1433,7 +1433,7 @@ namespace { case PatternKind::OptionalSome: { auto *OSP = cast(item); auto &Ctx = OSP->getElementDecl()->getASTContext(); - Identifier name = Ctx.getOptionalSomeDecl()->getName(); + const Identifier name = Ctx.getOptionalSomeDecl()->getBaseIdentifier(); auto subSpace = projectPattern(OSP->getSubPattern()); // To match patterns like (_, _, ...)?, we must rewrite the underlying From c63b737e92faf812c1d87db2748c5a7c95a186d4 Mon Sep 17 00:00:00 2001 From: Anthony Latsis Date: Tue, 24 Mar 2020 11:49:33 +0300 Subject: [PATCH 2/2] Collapse all indirect equivalents to ValueDecl::getBaseIdentifier --- include/swift/AST/Decl.h | 14 +++++++------- lib/AST/Decl.cpp | 8 ++++---- lib/AST/SwiftNameTranslation.cpp | 2 +- lib/AST/USRGeneration.cpp | 2 +- lib/ClangImporter/ClangImporter.cpp | 2 +- lib/ClangImporter/ImportDecl.cpp | 2 +- lib/IRGen/GenReflection.cpp | 2 +- lib/Migrator/APIDiffMigratorPass.cpp | 2 +- lib/Parse/ParseDecl.cpp | 2 +- lib/SILGen/SILGenBuiltin.cpp | 2 +- lib/SILGen/SILGenFunction.cpp | 2 +- lib/SILGen/SILGenLValue.cpp | 2 +- .../Mandatory/DIMemoryUseCollector.cpp | 2 +- lib/Sema/CSApply.cpp | 2 +- lib/Sema/CSDiagnostics.cpp | 12 ++++++------ lib/Sema/ConstraintSystem.cpp | 2 +- lib/Sema/MiscDiagnostics.cpp | 6 +++--- lib/Sema/TypeCheckAttr.cpp | 2 +- lib/Sema/TypeCheckCaptures.cpp | 2 +- lib/Sema/TypeCheckDecl.cpp | 4 ++-- lib/Sema/TypeCheckDeclOverride.cpp | 6 +++--- lib/Sema/TypeCheckDeclPrimary.cpp | 2 +- lib/Sema/TypeCheckExpr.cpp | 6 +++--- 23 files changed, 44 insertions(+), 44 deletions(-) diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index f0f749969bc73..b367478e660ea 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -2497,7 +2497,7 @@ class ValueDecl : public Decl { DeclBaseName getBaseName() const { return Name.getBaseName(); } Identifier getBaseIdentifier() const { - return getFullName().getBaseIdentifier(); + return Name.getBaseIdentifier(); } /// Generates a DeclNameRef referring to this declaration with as much @@ -2828,12 +2828,12 @@ class TypeDecl : public ValueDecl { ValueDecl(K, context, name, NameLoc), Inherited(inherited) {} public: - Identifier getName() const { return getFullName().getBaseIdentifier(); } + Identifier getName() const { return getBaseIdentifier(); } /// 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() ? getBaseName().getIdentifier().str() : "_"; + return hasName() ? getBaseIdentifier().str() : "_"; } /// The type of this declaration's values. For the type of the @@ -4915,12 +4915,12 @@ class VarDecl : public AbstractStorageDecl { SourceRange getSourceRange() const; - Identifier getName() const { return getFullName().getBaseIdentifier(); } + Identifier getName() const { return getBaseIdentifier(); } /// 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() ? getBaseName().getIdentifier().str() : "_"; + return hasName() ? getBaseIdentifier().str() : "_"; } /// Get the type of the variable within its context. If the context is generic, @@ -5895,7 +5895,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"); - return hasName() ? getBaseName().getIdentifier().str() : "_"; + return hasName() ? getBaseIdentifier().str() : "_"; } /// Should this declaration be treated as if annotated with transparent @@ -6588,7 +6588,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"); - return hasName() ? getBaseName().getIdentifier().str() : "_"; + return hasName() ? getBaseIdentifier().str() : "_"; } Type getArgumentInterfaceType() const; diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 658eef9ff46f8..6edfbbd12e080 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -760,7 +760,7 @@ bool Decl::hasUnderscoredNaming() const { } if (!VD->getBaseName().isSpecial() && - VD->getBaseName().getIdentifier().str().startswith("_")) { + VD->getBaseIdentifier().str().startswith("_")) { return true; } @@ -3167,7 +3167,7 @@ bool ValueDecl::shouldHideFromEditor() const { // '$__' names are reserved by compiler internal. if (!getBaseName().isSpecial() && - getBaseName().getIdentifier().str().startswith("$__")) + getBaseIdentifier().str().startswith("$__")) return true; return false; @@ -3586,8 +3586,8 @@ int TypeDecl::compare(const TypeDecl *type1, const TypeDecl *type2) { return result; } - if (int result = type1->getBaseName().getIdentifier().str().compare( - type2->getBaseName().getIdentifier().str())) + if (int result = type1->getBaseIdentifier().str().compare( + type2->getBaseIdentifier().str())) return result; // Error case: two type declarations that cannot be distinguished. diff --git a/lib/AST/SwiftNameTranslation.cpp b/lib/AST/SwiftNameTranslation.cpp index abe9443e0ebb8..bf6bb622d8346 100644 --- a/lib/AST/SwiftNameTranslation.cpp +++ b/lib/AST/SwiftNameTranslation.cpp @@ -49,7 +49,7 @@ getNameForObjC(const ValueDecl *VD, CustomNamesOnly_t customNamesOnly) { return anonTypedef->getIdentifier()->getName(); } - return VD->getBaseName().getIdentifier().str(); + return VD->getBaseIdentifier().str(); } std::string swift::objc_translation:: diff --git a/lib/AST/USRGeneration.cpp b/lib/AST/USRGeneration.cpp index 80bdfe3722859..30716b9f498c8 100644 --- a/lib/AST/USRGeneration.cpp +++ b/lib/AST/USRGeneration.cpp @@ -225,7 +225,7 @@ swift::USRGenerationRequest::evaluate(Evaluator &evaluator, auto ClangMacroInfo = ClangN.getAsMacro(); bool Ignore = clang::index::generateUSRForMacro( - D->getBaseName().getIdentifier().str(), + D->getBaseIdentifier().str(), ClangMacroInfo->getDefinitionLoc(), Importer.getClangASTContext().getSourceManager(), Buffer); if (!Ignore) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 4af873767bd1e..47da565243d2f 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -2414,7 +2414,7 @@ class DarwinLegacyFilterDeclConsumer : public swift::VisibleDeclConsumer { if (clangModule->Name == "MacTypes") { if (!VD->hasName() || VD->getBaseName().isSpecial()) return true; - return llvm::StringSwitch(VD->getBaseName().getIdentifier().str()) + return llvm::StringSwitch(VD->getBaseIdentifier().str()) .Cases("OSErr", "OSStatus", "OptionBits", false) .Cases("FourCharCode", "OSType", false) .Case("Boolean", false) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 5dfbed6aaa3de..f2b715f9233ff 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3202,7 +3202,7 @@ namespace { // context. if (errorWrapper) { auto enumeratorValue = cast(enumeratorDecl); - auto name = enumeratorValue->getBaseName().getIdentifier(); + auto name = enumeratorValue->getBaseIdentifier(); auto alias = importEnumCaseAlias(name, constant, enumeratorValue, diff --git a/lib/IRGen/GenReflection.cpp b/lib/IRGen/GenReflection.cpp index a8a291c832809..9ad5cc54ac19b 100644 --- a/lib/IRGen/GenReflection.cpp +++ b/lib/IRGen/GenReflection.cpp @@ -693,7 +693,7 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder { } if (IGM.IRGen.Opts.EnableReflectionNames) { - auto name = value->getBaseName().getIdentifier().str(); + auto name = value->getBaseIdentifier().str(); auto fieldName = IGM.getAddrOfFieldName(name); B.addRelativeAddress(fieldName); } else { diff --git a/lib/Migrator/APIDiffMigratorPass.cpp b/lib/Migrator/APIDiffMigratorPass.cpp index 203a573d49727..35a30946f83d1 100644 --- a/lib/Migrator/APIDiffMigratorPass.cpp +++ b/lib/Migrator/APIDiffMigratorPass.cpp @@ -386,7 +386,7 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker { for (auto *D: TopDecls) { if (auto *FD = dyn_cast(D)) { InsertedFunctions.insert( - std::string(FD->getBaseName().getIdentifier())); + std::string(FD->getBaseIdentifier())); } } diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 8ec55b7eaa1ce..b588e4883c183 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3519,7 +3519,7 @@ void Parser::setLocalDiscriminator(ValueDecl *D) { if (!getScopeInfo().isInactiveConfigBlock()) SF.LocalTypeDecls.insert(TD); - Identifier name = D->getBaseName().getIdentifier(); + const Identifier name = D->getBaseIdentifier(); unsigned discriminator = CurLocalContext->claimNextNamedDiscriminator(name); D->setLocalDiscriminator(discriminator); } diff --git a/lib/SILGen/SILGenBuiltin.cpp b/lib/SILGen/SILGenBuiltin.cpp index 8ba39d4204adb..4144a58c62531 100644 --- a/lib/SILGen/SILGenBuiltin.cpp +++ b/lib/SILGen/SILGenBuiltin.cpp @@ -1355,7 +1355,7 @@ SpecializedEmitter::forDecl(SILGenModule &SGM, SILDeclRef function) { if (!isa(decl->getDeclContext())) return None; - auto name = decl->getBaseName().getIdentifier(); + const auto name = decl->getBaseIdentifier(); const BuiltinInfo &builtin = SGM.M.getBuiltinInfo(name); switch (builtin.ID) { // All the non-SIL, non-type-trait builtins should use the diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp index c355e49fc4d65..ce3d5ee63cb74 100644 --- a/lib/SILGen/SILGenFunction.cpp +++ b/lib/SILGen/SILGenFunction.cpp @@ -253,7 +253,7 @@ void SILGenFunction::emitCaptures(SILLocation loc, isDeferBody ? diag::capture_before_declaration_defer : diag::capture_before_declaration, - vd->getBaseName().getIdentifier()); + vd->getBaseIdentifier()); Diags.diagnose(vd->getLoc(), diag::captured_value_declared_here); Diags.diagnose(capture.getLoc(), diag::value_captured_here); diff --git a/lib/SILGen/SILGenLValue.cpp b/lib/SILGen/SILGenLValue.cpp index f7823a557f5d1..8fa86fa4c2994 100644 --- a/lib/SILGen/SILGenLValue.cpp +++ b/lib/SILGen/SILGenLValue.cpp @@ -153,7 +153,7 @@ void ExclusiveBorrowFormalAccess::diagnoseConflict( if (!lhsStorage->Indices) { assert(isa(storage)); SGF.SGM.diagnose(loc, diag::writeback_overlap_property, - storage->getBaseName().getIdentifier()) + storage->getBaseIdentifier()) .highlight(loc.getSourceRange()); SGF.SGM.diagnose(rhs.loc, diag::writebackoverlap_note) .highlight(rhs.loc.getSourceRange()); diff --git a/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp b/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp index 00ed41f14eb8c..8bbb9d30ed1aa 100644 --- a/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp +++ b/lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp @@ -351,7 +351,7 @@ DIMemoryObjectInfo::getPathStringToElement(unsigned Element, Result = "self"; else if (ValueDecl *VD = dyn_cast_or_null(getLoc().getAsASTNode())) - Result = std::string(VD->getBaseName().getIdentifier()); + Result = std::string(VD->getBaseIdentifier()); else Result = ""; diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp index 040fabff2992a..85888ebbc11e7 100644 --- a/lib/Sema/CSApply.cpp +++ b/lib/Sema/CSApply.cpp @@ -2844,7 +2844,7 @@ namespace { // assigned case comes from Optional if (auto EED = dyn_cast(calledValue)) { isOptional = EED->getParentEnum()->isOptionalDecl(); - memberName = EED->getBaseName().getIdentifier(); + memberName = EED->getBaseIdentifier(); } // Return if the enum case doesn't come from Optional diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index f7d45d7028979..4d05ef0fe7e63 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -1461,7 +1461,7 @@ bool AssignmentFailure::diagnoseAsError() { std::string message = "key path is read-only"; if (auto *SE = dyn_cast(immutableExpr)) { if (auto *DRE = dyn_cast(getKeyPathArgument(SE))) { - auto identifier = DRE->getDecl()->getBaseName().getIdentifier(); + auto identifier = DRE->getDecl()->getBaseIdentifier(); message = "'" + identifier.str().str() + "' is a read-only key path"; } @@ -1574,7 +1574,7 @@ bool AssignmentFailure::diagnoseAsError() { // If we're trying to set an unapplied method, say that. if (auto *VD = choice->getDecl()) { std::string message = "'"; - message += VD->getBaseName().getIdentifier().str(); + message += VD->getBaseIdentifier().str(); message += "'"; auto diagID = DeclDiagnostic; @@ -1639,7 +1639,7 @@ bool AssignmentFailure::diagnoseAsError() { if (auto *DRE = dyn_cast(AE->getFn()->getValueProvidingExpr())) name = std::string("'") + - DRE->getDecl()->getBaseName().getIdentifier().str().str() + "'"; + DRE->getDecl()->getBaseIdentifier().str().str() + "'"; emitDiagnostic(Loc, DeclDiagnostic, name + " returns immutable value") .highlight(AE->getSourceRange()); @@ -3060,7 +3060,7 @@ bool MissingCallFailure::diagnoseAsError() { if (auto *DRE = dyn_cast(baseExpr)) { emitDiagnostic(baseExpr->getLoc(), diag::did_not_call_function, - DRE->getDecl()->getBaseName().getIdentifier()) + DRE->getDecl()->getBaseIdentifier()) .fixItInsertAfter(insertLoc, "()"); return true; } @@ -3075,7 +3075,7 @@ bool MissingCallFailure::diagnoseAsError() { if (auto *DSCE = dyn_cast(baseExpr)) { if (auto *DRE = dyn_cast(DSCE->getFn())) { emitDiagnostic(baseExpr->getLoc(), diag::did_not_call_method, - DRE->getDecl()->getBaseName().getIdentifier()) + DRE->getDecl()->getBaseIdentifier()) .fixItInsertAfter(insertLoc, "()"); return true; } @@ -3200,7 +3200,7 @@ DeclName MissingMemberFailure::findCorrectEnumCaseName( auto candidate = corrections.getUniqueCandidateMatching([&](ValueDecl *candidate) { return (isa(candidate) && - candidate->getFullName().getBaseIdentifier().str().equals_lower( + candidate->getBaseIdentifier().str().equals_lower( memberName.getBaseIdentifier().str())); }); return (candidate ? candidate->getFullName() : DeclName()); diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index 0dfc851d05598..d9c203dead0e3 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -3870,7 +3870,7 @@ Optional constraints::getOperatorName(Expr *expr) { } if (auto *FD = dyn_cast_or_null(choice)) - return FD->getBaseName().getIdentifier(); + return FD->getBaseIdentifier(); return None; } diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 3360edd2aa261..664ec5d01e447 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -597,7 +597,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC, } Ctx.Diags.diagnose(DRE->getLoc(), diag::warn_unqualified_access, - VD->getBaseName().getIdentifier(), + VD->getBaseIdentifier(), VD->getDescriptiveKind(), declParent->getDescriptiveKind(), declParent->getFullName()); @@ -656,7 +656,7 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC, if (TypeChecker::getDeclTypeCheckingSemantics(DRE->getDecl()) != DeclTypeCheckingSemantics::Normal) { Ctx.Diags.diagnose(DRE->getLoc(), diag::unsupported_special_decl_ref, - DRE->getDecl()->getBaseName().getIdentifier()); + DRE->getDecl()->getBaseIdentifier()); } } @@ -1504,7 +1504,7 @@ static void diagnoseImplicitSelfUseInClosure(const Expr *E, memberLoc = DSCE->getLoc(); Diags.diagnose(DSCE->getLoc(), diag::method_call_in_closure_without_explicit_self, - MethodExpr->getDecl()->getBaseName().getIdentifier()); + MethodExpr->getDecl()->getBaseIdentifier()); } if (memberLoc.isValid()) { diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 02f7a0d555b13..cb2dbd77323cb 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -479,7 +479,7 @@ void AttributeChecker::visitIBSegueActionAttr(IBSegueActionAttr *attr) { // explicit selector. if (!FD->getAttrs().hasAttribute() || !FD->getAttrs().getAttribute()->hasName()) { - auto newSwiftBaseName = replacingPrefix(FD->getBaseName().getIdentifier()); + auto newSwiftBaseName = replacingPrefix(FD->getBaseIdentifier()); auto argumentNames = FD->getFullName().getArgumentNames(); DeclName newSwiftName(Ctx, newSwiftBaseName, argumentNames); diff --git a/lib/Sema/TypeCheckCaptures.cpp b/lib/Sema/TypeCheckCaptures.cpp index d9173b384bde1..d7bcf9fad7f12 100644 --- a/lib/Sema/TypeCheckCaptures.cpp +++ b/lib/Sema/TypeCheckCaptures.cpp @@ -291,7 +291,7 @@ class FindCapturedVars : public ASTWalker { if (DC->isLocalContext()) { Context.Diags.diagnose(DRE->getLoc(), diag::capture_across_type_decl, NTD->getDescriptiveKind(), - D->getBaseName().getIdentifier()); + D->getBaseIdentifier()); NTD->diagnose(diag::kind_declared_here, DescriptiveDeclKind::Type); diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index 79dee1f60add4..99b7c1187a70f 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -666,7 +666,7 @@ IsStaticRequest::evaluate(Evaluator &evaluator, FuncDecl *decl) const { if (!result && decl->isOperator() && dc->isTypeContext()) { - auto operatorName = decl->getFullName().getBaseIdentifier(); + const auto operatorName = decl->getBaseIdentifier(); if (auto ED = dyn_cast(dc->getAsDecl())) { decl->diagnose(diag::nonstatic_operator_in_extension, operatorName, ED->getExtendedTypeRepr()) @@ -1706,7 +1706,7 @@ OperatorDecl * FunctionOperatorRequest::evaluate(Evaluator &evaluator, FuncDecl *FD) const { auto &C = FD->getASTContext(); auto &diags = C.Diags; - auto operatorName = FD->getFullName().getBaseIdentifier(); + const auto operatorName = FD->getBaseIdentifier(); // Check for static/final/class when we're in a type. auto dc = FD->getDeclContext(); diff --git a/lib/Sema/TypeCheckDeclOverride.cpp b/lib/Sema/TypeCheckDeclOverride.cpp index 027044e2aac05..af5bda25e382d 100644 --- a/lib/Sema/TypeCheckDeclOverride.cpp +++ b/lib/Sema/TypeCheckDeclOverride.cpp @@ -1705,7 +1705,7 @@ static bool checkSingleOverride(ValueDecl *override, ValueDecl *base) { diag::override_with_stored_property_warn : diag::override_with_stored_property; diags.diagnose(overrideASD, diagID, - overrideASD->getBaseName().getIdentifier()); + overrideASD->getBaseIdentifier()); diags.diagnose(baseASD, diag::property_override_here); if (!downgradeToWarning) return true; @@ -1722,7 +1722,7 @@ static bool checkSingleOverride(ValueDecl *override, ValueDecl *base) { if (overrideASD->getWriteImpl() == WriteImplKind::InheritedWithObservers && !baseIsSettable) { diags.diagnose(overrideASD, diag::observing_readonly_property, - overrideASD->getBaseName().getIdentifier()); + overrideASD->getBaseIdentifier()); diags.diagnose(baseASD, diag::property_override_here); return true; } @@ -1732,7 +1732,7 @@ static bool checkSingleOverride(ValueDecl *override, ValueDecl *base) { // setter but override the getter, and that would be surprising at best. if (baseIsSettable && !overrideASD->isSettable(override->getDeclContext())) { diags.diagnose(overrideASD, diag::override_mutable_with_readonly_property, - overrideASD->getBaseName().getIdentifier()); + overrideASD->getBaseIdentifier()); diags.diagnose(baseASD, diag::property_override_here); return true; } diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index e7cc9f2707b0c..ffbcd8d743f59 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -1274,7 +1274,7 @@ class DeclChecker : public DeclVisitor { Context.SourceMgr.extractText({VD->getNameLoc(), 1}) != "`") { auto &DE = getASTContext().Diags; DE.diagnose(VD->getNameLoc(), diag::reserved_member_name, - VD->getFullName(), VD->getBaseName().getIdentifier().str()); + VD->getFullName(), VD->getBaseIdentifier().str()); DE.diagnose(VD->getNameLoc(), diag::backticks_to_escape) .fixItReplace(VD->getNameLoc(), "`" + VD->getBaseName().userFacingName().str() + "`"); diff --git a/lib/Sema/TypeCheckExpr.cpp b/lib/Sema/TypeCheckExpr.cpp index 896f326c136f8..c4478a73d6cec 100644 --- a/lib/Sema/TypeCheckExpr.cpp +++ b/lib/Sema/TypeCheckExpr.cpp @@ -178,12 +178,12 @@ TypeChecker::lookupPrecedenceGroupForInfixOperator(DeclContext *DC, Expr *E) { } if (auto *DRE = dyn_cast(E)) { - Identifier name = DRE->getDecl()->getBaseName().getIdentifier(); + Identifier name = DRE->getDecl()->getBaseIdentifier(); return lookupPrecedenceGroupForOperator(DC, name, DRE->getLoc()); } if (auto *OO = dyn_cast(E)) { - Identifier name = OO->getDecls()[0]->getBaseName().getIdentifier(); + Identifier name = OO->getDecls()[0]->getBaseIdentifier(); return lookupPrecedenceGroupForOperator(DC, name, OO->getLoc()); } @@ -204,7 +204,7 @@ TypeChecker::lookupPrecedenceGroupForInfixOperator(DeclContext *DC, Expr *E) { } if (auto *MRE = dyn_cast(E)) { - Identifier name = MRE->getDecl().getDecl()->getBaseName().getIdentifier(); + Identifier name = MRE->getDecl().getDecl()->getBaseIdentifier(); return lookupPrecedenceGroupForOperator(DC, name, MRE->getLoc()); }