[Mlir-commits] [mlir] [mlir][Pass] Handle escaped pipline option values (PR #97667)

Matthias Springer llvmlistbot at llvm.org
Fri Jul 5 00:49:38 PDT 2024


================
@@ -60,6 +60,20 @@ template <typename ParserT>
 static void printOptionValue(raw_ostream &os, const bool &value) {
   os << (value ? StringRef("true") : StringRef("false"));
 }
+template <typename ParserT>
+static void printOptionValue(raw_ostream &os, const std::string &str) {
+  // Check if the string needs to be escaped before writing it to the ostream.
+  const size_t spaceIndex = str.find_first_of(' ');
+  const size_t escapeIndex =
+      std::min({str.find_first_of('{'), str.find_first_of('\''),
+                str.find_first_of('"')});
+  const bool requiresEscape = spaceIndex < escapeIndex;
----------------
matthias-springer wrote:

Thanks!

https://github.com/llvm/llvm-project/pull/97667


More information about the Mlir-commits mailing list