[PATCH] D43919: Use Twine rather than StringRef for logging messages. NFC.

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 16:45:38 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD326398: [WebAssembly] Use Twine rather than StringRef for logging messages (authored by sbc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43919?vs=136426&id=136432#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43919

Files:
  wasm/WriterUtils.cpp
  wasm/WriterUtils.h


Index: wasm/WriterUtils.cpp
===================================================================
--- wasm/WriterUtils.cpp
+++ wasm/WriterUtils.cpp
@@ -40,37 +40,40 @@
   DEBUG(dbgs() << format("  | %08lld: ", Offset) << Msg << "\n");
 }
 
-void wasm::writeUleb128(raw_ostream &OS, uint32_t Number, StringRef Msg) {
+void wasm::writeUleb128(raw_ostream &OS, uint32_t Number, const Twine &Msg) {
   debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
   encodeULEB128(Number, OS);
 }
 
-void wasm::writeSleb128(raw_ostream &OS, int32_t Number, StringRef Msg) {
+void wasm::writeSleb128(raw_ostream &OS, int32_t Number, const Twine &Msg) {
   debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
   encodeSLEB128(Number, OS);
 }
 
 void wasm::writeBytes(raw_ostream &OS, const char *Bytes, size_t Count,
-                      StringRef Msg) {
+                      const Twine &Msg) {
   debugWrite(OS.tell(), Msg + " [data[" + Twine(Count) + "]]");
   OS.write(Bytes, Count);
 }
 
-void wasm::writeStr(raw_ostream &OS, StringRef String, StringRef Msg) {
+void wasm::writeStr(raw_ostream &OS, StringRef String, const Twine &Msg) {
   debugWrite(OS.tell(),
              Msg + " [str[" + Twine(String.size()) + "]: " + String + "]");
   encodeULEB128(String.size(), OS);
   OS.write(String.data(), String.size());
 }
 
-void wasm::writeU8(raw_ostream &OS, uint8_t Byte, StringRef Msg) { OS << Byte; }
+void wasm::writeU8(raw_ostream &OS, uint8_t Byte, const Twine &Msg) {
+  debugWrite(OS.tell(), Msg + " [0x" + utohexstr(Byte) + "]");
+  OS << Byte;
+}
 
-void wasm::writeU32(raw_ostream &OS, uint32_t Number, StringRef Msg) {
-  debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
+void wasm::writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg) {
+  debugWrite(OS.tell(), Msg + "[0x" + utohexstr(Number) + "]");
   support::endian::Writer<support::little>(OS).write(Number);
 }
 
-void wasm::writeValueType(raw_ostream &OS, int32_t Type, StringRef Msg) {
+void wasm::writeValueType(raw_ostream &OS, int32_t Type, const Twine &Msg) {
   debugWrite(OS.tell(), Msg + "[type: " + valueTypeToString(Type) + "]");
   encodeSLEB128(Type, OS);
 }
Index: wasm/WriterUtils.h
===================================================================
--- wasm/WriterUtils.h
+++ wasm/WriterUtils.h
@@ -44,19 +44,20 @@
 
 void debugWrite(uint64_t Offset, const Twine &Msg);
 
-void writeUleb128(raw_ostream &OS, uint32_t Number, StringRef Msg);
+void writeUleb128(raw_ostream &OS, uint32_t Number, const Twine &Msg);
 
-void writeSleb128(raw_ostream &OS, int32_t Number, StringRef Msg);
+void writeSleb128(raw_ostream &OS, int32_t Number, const Twine &Msg);
 
-void writeBytes(raw_ostream &OS, const char *Bytes, size_t count, StringRef Msg);
+void writeBytes(raw_ostream &OS, const char *Bytes, size_t count,
+                const Twine &Msg);
 
-void writeStr(raw_ostream &OS, StringRef String, StringRef Msg);
+void writeStr(raw_ostream &OS, StringRef String, const Twine &Msg);
 
-void writeU8(raw_ostream &OS, uint8_t byte, StringRef Msg);
+void writeU8(raw_ostream &OS, uint8_t byte, const Twine &Msg);
 
-void writeU32(raw_ostream &OS, uint32_t Number, StringRef Msg);
+void writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg);
 
-void writeValueType(raw_ostream &OS, int32_t Type, StringRef Msg);
+void writeValueType(raw_ostream &OS, int32_t Type, const Twine &Msg);
 
 void writeSig(raw_ostream &OS, const llvm::wasm::WasmSignature &Sig);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43919.136432.patch
Type: text/x-patch
Size: 3472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180301/cf9fdae1/attachment-0001.bin>


More information about the llvm-commits mailing list