[PATCH] D44323: [WebAssembly] Remove a second parameter from toString().

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 9 12:51:46 PST 2018


ruiu created this revision.
ruiu added reviewers: sbc100, ncw.
Herald added subscribers: sunfish, aheejin, jgravelle-google, dschuff, jfb.

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.


https://reviews.llvm.org/D44323

Files:
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h


Index: lld/wasm/Symbols.h
===================================================================
--- lld/wasm/Symbols.h
+++ lld/wasm/Symbols.h
@@ -312,7 +312,7 @@
 } // 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);
 
Index: lld/wasm/Symbols.cpp
===================================================================
--- lld/wasm/Symbols.cpp
+++ lld/wasm/Symbols.cpp
@@ -180,10 +180,10 @@
 
 void LazySymbol::fetch() { cast<ArchiveFile>(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<std::string> S = demangleItanium(Sym.getName()))
-      return QuoteDemangled ? ("`" + *S + "'") : *S;
+      return *S;
   return Sym.getName();
 }
 
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -240,7 +240,7 @@
     // 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));
+        Saver.save("undefined function " + toString(*Sym));
     SyntheticFunction *Func = make<SyntheticFunction>(Sig, StubName);
     Func->setBody(UnreachableFn);
     // Ensure it compares equal to the null pointer, and so that table relocs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44323.137818.patch
Type: text/x-patch
Size: 1679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180309/ef23e432/attachment.bin>


More information about the llvm-commits mailing list