mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName` instead of an `Identifier`. All places that will continue to be expecting an `Identifier` are changed to call `getBaseIdentifier` which will later assert that the `DeclName` is actually backed by an identifier and not a special name. For transitional purposes, a conversion operator from `DeclBaseName` to `Identifier` has been added that will be removed again once migration to DeclBaseName has been completed in other parts of the compiler. Unify approach to printing declaration names Printing a declaration's name using `<<` and `getBaseName()` is be independent of the return type of `getBaseName()` which will change in the future from `Identifier` to `DeclBaseName`
This commit is contained in:
@@ -1004,7 +1004,8 @@ static StringRef getPrintedName(SDKContext &Ctx, ValueDecl *VD) {
|
||||
if (auto FD = dyn_cast<AbstractFunctionDecl>(VD)) {
|
||||
auto DM = FD->getFullName();
|
||||
|
||||
Result.append(DM.getBaseName().empty() ? "_" : DM.getBaseName().str());
|
||||
// TODO: Handle special names
|
||||
Result.append(DM.getBaseName().empty() ? "_" :DM.getBaseIdentifier().str());
|
||||
Result.append("(");
|
||||
for (auto Arg : DM.getArgumentNames()) {
|
||||
Result.append(Arg.empty() ? "_" : Arg.str());
|
||||
@@ -1014,7 +1015,8 @@ static StringRef getPrintedName(SDKContext &Ctx, ValueDecl *VD) {
|
||||
return Ctx.buffer(Result.str());
|
||||
}
|
||||
auto DM = VD->getFullName();
|
||||
Result.append(DM.getBaseName().str());
|
||||
// TODO: Handle special names
|
||||
Result.append(DM.getBaseIdentifier().str());
|
||||
return Ctx.buffer(Result.str());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user