Skip to content

Commit c14cbe0

Browse files
committed
ASTMangler: Add mangleTypeAsUSR()
For now this just duplicates mangleTypeForDebugger(), but the latter's behavior is going to change.
1 parent 4ab3535 commit c14cbe0

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ class ASTMangler : public Mangler {
169169
return finalize();
170170
}
171171

172+
std::string mangleTypeAsUSR(Type decl);
173+
172174
std::string mangleTypeAsContextUSR(const NominalTypeDecl *type);
173175

174176
std::string mangleDeclAsUSR(const ValueDecl *Decl, StringRef USRPrefix);

lib/AST/ASTMangler.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,20 @@ std::string ASTMangler::mangleTypeAsContextUSR(const NominalTypeDecl *type) {
468468
return finalize();
469469
}
470470

471+
std::string ASTMangler::mangleTypeAsUSR(Type Ty) {
472+
DWARFMangling = true;
473+
beginMangling();
474+
475+
if (auto *fnType = Ty->getAs<AnyFunctionType>()) {
476+
appendFunction(fnType, false);
477+
} else {
478+
appendType(Ty);
479+
}
480+
481+
appendOperator("D");
482+
return finalize();
483+
}
484+
471485
std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
472486
StringRef USRPrefix) {
473487
beginManglingWithoutPrefix();

lib/AST/USRGeneration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static inline StringRef getUSRSpacePrefix() {
3535
bool ide::printTypeUSR(Type Ty, raw_ostream &OS) {
3636
assert(!Ty->hasArchetype() && "cannot have contextless archetypes mangled.");
3737
Mangle::ASTMangler Mangler;
38-
OS << Mangler.mangleTypeForDebugger(Ty->getRValueType(), nullptr);
38+
OS << Mangler.mangleTypeAsUSR(Ty->getRValueType());
3939
return false;
4040
}
4141

0 commit comments

Comments
 (0)