File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -258,8 +258,7 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
258258 void emitAbstractFunctionDecl (swift::AbstractFunctionDecl* decl,
259259 TrapLabel<AbstractFunctionDeclTag> label) {
260260 assert (decl->hasParameterList () && " Expect functions to have a parameter list" );
261- auto name = !decl->hasName () || decl->getName ().isSpecial () ? " (unnamed function decl)"
262- : decl->getNameStr ().str ();
261+ auto name = !decl->hasName () ? " (unnamed function decl)" : constructName (decl->getName ());
263262 dispatcher_.emit (AbstractFunctionDeclsTrap{label, name});
264263 if (auto body = decl->getBody ()) {
265264 dispatcher_.emit (AbstractFunctionDeclBodiesTrap{label, dispatcher_.fetchLabel (body)});
@@ -355,6 +354,22 @@ class DeclVisitor : public AstVisitorBase<DeclVisitor> {
355354 emitValueDecl (decl, label);
356355 }
357356
357+ // Constructs a `std::string` of the form `f(x:y:)` for a declaration
358+ // like `func f(x first: Int, y second: Int) { }`
359+ std::string constructName (swift::DeclName declName) {
360+ std::string name = declName.getBaseName ().userFacingName ().str ();
361+ name += " (" ;
362+ for (auto argName : declName.getArgumentNames ()) {
363+ if (argName.empty ()) {
364+ name += " _:" ;
365+ } else {
366+ name += argName.str ().str () + " :" ;
367+ }
368+ }
369+ name += " )" ;
370+ return name;
371+ }
372+
358373 private:
359374 swift::Mangle::ASTMangler mangler;
360375};
You can’t perform that action at this time.
0 commit comments