Refactor wasm/WriterUtil.{cpp,h}.

Summary:
 - Makes code more in line with LLVM style (e.g. const char * -> StringRef)
 - Do not use formatv since we can construct message just by `+`
 - Replace some odd types such as `const StringRef` with more common type
 - Do not use default arguments if they are not necessary

Reviewers: sbc100

Subscribers: jfb, aheejin, llvm-commits, sunfish

Differential Revision: https://reviews.llvm.org/D43403

llvm-svn: 325383
diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp
index b34a2c0..b952a45 100644
--- a/lld/wasm/OutputSections.cpp
+++ b/lld/wasm/OutputSections.cpp
@@ -15,6 +15,7 @@
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Threads.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/LEB128.h"
 
 #define DEBUG_TYPE "lld"
 
@@ -72,7 +73,7 @@
 void OutputSection::createHeader(size_t BodySize) {
   raw_string_ostream OS(Header);
   debugWrite(OS.tell(), "section type [" + Twine(getSectionName()) + "]");
-  writeUleb128(OS, Type, nullptr);
+  encodeULEB128(Type, OS);
   writeUleb128(OS, BodySize, "section size");
   OS.flush();
   log("createHeader: " + toString(*this) + " body=" + Twine(BodySize) +