[PATCH] D48271: [llvm-readobj] Fix printing format

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 26 14:25:23 PDT 2018


dblaikie added inline comments.


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:4281-4284
+      if (isprint(CurrentWord[i]))
+        W.startLine() << CurrentWord[i];
+      else
+        W.startLine() << '.';
----------------
Maybe factor this out into a utility:

  char ToPrintable(char X) { 
    return isprint(X) ? X : '.';
  }

and/or pulling out the whole loop into a utility, since it's duplicated in these two places:

  void PrintAsPrintable(ScopedPrinter& W, StringRef S) {
    for (char C : S)
      W.startLine() << (isprint(C) ? C : '.');
  }
  ...
  PrintAsPrintable(W, StringRef(CurrentWord, WordSize));


Repository:
  rL LLVM

https://reviews.llvm.org/D48271





More information about the llvm-commits mailing list