Skip to content

Commit 9f33bc9

Browse files
committed
Mangler: add a beginManglingWithoutPrefix function
Mostly cosmetic, because usually the mangling functions are called only once per mangling instance anyway.
1 parent d342041 commit 9f33bc9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

include/swift/Basic/Mangler.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ class Mangler {
9494

9595
Mangler() : Buffer(Storage) { }
9696

97-
/// Adds the mangling prefix.
97+
/// Begins a new mangling but does not add the mangling prefix.
98+
void beginManglingWithoutPrefix();
99+
100+
/// Begins a new mangling but and adds the mangling prefix.
98101
void beginMangling();
99102

100103
/// Finish the mangling of the symbol and return the mangled name.

lib/AST/ASTMangler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,15 @@ std::string ASTMangler::mangleObjCRuntimeName(const NominalTypeDecl *Nominal) {
386386
}
387387

388388
std::string ASTMangler::mangleTypeAsContextUSR(const NominalTypeDecl *type) {
389+
beginManglingWithoutPrefix();
389390
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
390391
appendContext(type);
391392
return finalize();
392393
}
393394

394395
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
395396
StringRef USRPrefix) {
397+
beginManglingWithoutPrefix();
396398
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
397399
Buffer << USRPrefix;
398400
bindGenericParameters(Decl->getDeclContext());
@@ -419,6 +421,7 @@ std::string ASTMangler::mangleAccessorEntityAsUSR(AccessorKind kind,
419421
AddressorKind addressorKind,
420422
const ValueDecl *decl,
421423
StringRef USRPrefix) {
424+
beginManglingWithoutPrefix();
422425
llvm::SaveAndRestore<bool> allowUnnamedRAII(AllowNamelessEntities, true);
423426
Buffer << USRPrefix;
424427
appendAccessorEntity(kind, addressorKind, decl, /*isStatic*/ false);

lib/Basic/Mangler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ void Mangle::printManglingStats() {
110110
#endif
111111
}
112112

113-
void Mangler::beginMangling() {
113+
void Mangler::beginManglingWithoutPrefix() {
114114
Storage.clear();
115115
Substitutions.clear();
116116
StringSubstitutions.clear();
117117
Words.clear();
118118
SubstMerging.clear();
119+
}
120+
121+
void Mangler::beginMangling() {
122+
beginManglingWithoutPrefix();
119123
Buffer << MANGLING_PREFIX_STR;
120124
}
121125

0 commit comments

Comments
 (0)