mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Mangler] Change the Swift mangler into a symbol builder.
This commit changes the Swift mangler from a utility that writes tokens into a stream into a name-builder that has two phases: "building a name", and "ready". This clear separation is needed for the implementation of the compression layer. Users of the mangler can continue to build the name using the mangleXXX methods, but to access the results the users of the mangler need to call the finalize() method. This method can write the result into a stream, like before, or return an std::string.
This commit is contained in:
@@ -3648,13 +3648,10 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
|
||||
for (auto TD : localTypeDecls) {
|
||||
hasLocalTypes = true;
|
||||
|
||||
SmallString<32> MangledName;
|
||||
llvm::raw_svector_ostream Stream(MangledName);
|
||||
{
|
||||
Mangle::Mangler DebugMangler(Stream, false);
|
||||
Mangle::Mangler DebugMangler(false);
|
||||
DebugMangler.mangleType(TD->getDeclaredType(),
|
||||
ResilienceExpansion::Minimal, 0);
|
||||
}
|
||||
auto MangledName = DebugMangler.finalize();
|
||||
assert(!MangledName.empty() && "Mangled type came back empty!");
|
||||
localTypeGenerator.insert(MangledName, {
|
||||
addDeclRef(TD), TD->getLocalDiscriminator()
|
||||
|
||||
Reference in New Issue
Block a user