From 72a9a2321f592f51163a8268fc8dcc1b3af72805 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 9 Mar 2018 22:59:34 +0000 Subject: [PATCH] [WebAssembly] Remove a second parameter from toString(). toString(T) is a stringize function for an object of type T. Each type that has that function defined should know how to stringize itself, and there should be one string representation of an object. Passing a "supplemental" argument to toString() breaks that princple. We shouldn't add a second parameter to that function. Differential Revision: https://reviews.llvm.org/D44323 llvm-svn: 327182 --- lld/wasm/Driver.cpp | 3 +-- lld/wasm/Symbols.cpp | 4 ++-- lld/wasm/Symbols.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 98d1f5d..0de180a 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -239,8 +239,7 @@ static void handleWeakUndefines() { // Add a synthetic dummy for weak undefined functions. These dummies will // be GC'd if not used as the target of any "call" instructions. - StringRef StubName = - Saver.save("undefined function " + toString(*Sym, false)); + StringRef StubName = Saver.save("undefined function " + toString(*Sym)); SyntheticFunction *Func = make(Sig, StubName); Func->setBody(UnreachableFn); // Ensure it compares equal to the null pointer, and so that table relocs diff --git a/lld/wasm/Symbols.cpp b/lld/wasm/Symbols.cpp index b1bf9b3..e2b6d3d 100644 --- a/lld/wasm/Symbols.cpp +++ b/lld/wasm/Symbols.cpp @@ -180,10 +180,10 @@ DefinedGlobal::DefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File, void LazySymbol::fetch() { cast(File)->addMember(&ArchiveSymbol); } -std::string lld::toString(const wasm::Symbol &Sym, bool QuoteDemangled) { +std::string lld::toString(const wasm::Symbol &Sym) { if (Config->Demangle) if (Optional S = demangleItanium(Sym.getName())) - return QuoteDemangled ? ("`" + *S + "'") : *S; + return *S; return Sym.getName(); } diff --git a/lld/wasm/Symbols.h b/lld/wasm/Symbols.h index 92acabb..76a7417 100644 --- a/lld/wasm/Symbols.h +++ b/lld/wasm/Symbols.h @@ -312,7 +312,7 @@ T *replaceSymbol(Symbol *S, ArgT &&... Arg) { } // namespace wasm // Returns a symbol name for an error message. -std::string toString(const wasm::Symbol &Sym, bool QuoteDemangled = true); +std::string toString(const wasm::Symbol &Sym); std::string toString(wasm::Symbol::Kind Kind); std::string toString(WasmSymbolType Type); -- 2.7.4