From d70b83d697f1431953df6a5c8a390ca1022810fa Mon Sep 17 00:00:00 2001 From: Youngsuk Kim Date: Mon, 25 Aug 2025 06:18:41 -0700 Subject: [PATCH] [mlir] Fix bug in PDLL Parser This reverts changes made to `mlir/lib/Tools/PDLL/Parser/Parser.cpp` in 095b41c6eedb3acc908dc63ee91ff77944c07d75 . `raw_indented_ostream::printReindented()` reads from a string to which it also concurrently writes to, causing unintended behavior. Credits to @jackalcooper for finding the issue. --- mlir/lib/Tools/PDLL/Parser/Parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp index 51e702a1bb53a..c883baa7be2c5 100644 --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -147,8 +147,9 @@ class Parser { std::string docStr; { llvm::raw_string_ostream docOS(docStr); + std::string tmpDocStr = doc.str(); raw_indented_ostream(docOS).printReindented( - StringRef(docStr).rtrim(" \t")); + StringRef(tmpDocStr).rtrim(" \t")); } return docStr; }