[PATCH] D23792: IR: Properly handle escape characters in Attribute::getAsString()

John McCall via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 15:50:24 PDT 2016


rjmccall added a comment.

Thank you, this looks better.  A minor suggestions and then this LGTM.


================
Comment at: include/llvm/ADT/StringExtras.h:19
@@ -18,2 +18,3 @@
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/raw_ostream.h"
 #include <iterator>
----------------
You should be able to just forward-declare raw_ostream in this header:

  namespace llvm {
  class raw_ostream;


================
Comment at: lib/IR/Attributes.cpp:394
@@ -388,1 +393,3 @@
+
+    Result += "=\"" + OS.str() + "\"";
     return Result;
----------------
I would suggest just printing this directly into Result, like so:

  {
    raw_string_ostream OS(Result);
    OS << "=\"";
    PrintEscapedString(AttrVal, OS);
    OS << "\"";
  }


https://reviews.llvm.org/D23792





More information about the llvm-commits mailing list