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:
Jordan Rose
2017-05-28 17:55:03 -07:00
committed by GitHub
parent f302afc97f
commit c0ccdb1626
29 changed files with 125 additions and 95 deletions

View File

@@ -935,7 +935,7 @@ static DeclName getSwiftDeclName(const ValueDecl *VD,
assert(SwiftLangSupport::getNameKindForUID(Info.NameKind) == NameKind::Swift);
DeclName OrigName = VD->getFullName();
Identifier BaseName = Info.BaseName.empty()
? OrigName.getBaseName()
? Identifier(OrigName.getBaseName())
: Ctx.getIdentifier(Info.BaseName);
auto OrigArgs = OrigName.getArgumentNames();
SmallVector<Identifier, 8> Args(OrigArgs.begin(), OrigArgs.end());
@@ -1006,7 +1006,7 @@ static bool passNameInfoForDecl(const ValueDecl *VD, NameTranslatingInfo &Info,
DeclName Name = Importer->importName(Named, ObjCName);
NameTranslatingInfo Result;
Result.NameKind = SwiftLangSupport::getUIDForNameKind(NameKind::Swift);
Result.BaseName = Name.getBaseName().str();
Result.BaseName = Name.getBaseIdentifier().str();
std::transform(Name.getArgumentNames().begin(),
Name.getArgumentNames().end(),
std::back_inserter(Result.ArgNames),