-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[YAML] fix output incorrect format for block scalar string #132897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
original #131694 closed due to miss-operation |
@llvm/pr-subscribers-objectyaml @llvm/pr-subscribers-llvm-support Author: Congcong Cai (HerrCai0907) ChangesAfter outputting block scalar string, the indent will be wrong. The new added ut will fail in main. @@ -3,4 +3,4 @@
Just a block
scalar doc
-scalar: a
+ scalar: a
...\n Full diff: https://github.com/llvm/llvm-project/pull/132897.diff 2 Files Affected:
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index 28642e004c4f4..035828b594e84 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -725,18 +725,18 @@ void Output::blockScalarString(StringRef &S) {
if (!StateStack.empty())
newLineCheck();
output(" |");
- outputNewLine();
unsigned Indent = StateStack.empty() ? 1 : StateStack.size();
auto Buffer = MemoryBuffer::getMemBuffer(S, "", false);
for (line_iterator Lines(*Buffer, false); !Lines.is_at_end(); ++Lines) {
+ outputNewLine();
for (unsigned I = 0; I < Indent; ++I) {
output(" ");
}
output(*Lines);
- outputNewLine();
}
+ outputUpToEndOfLine("");
}
void Output::scalarTag(std::string &Tag) {
diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp
index 3db1db57ad596..5a86555d08fb3 100644
--- a/llvm/unittests/Support/YAMLIOTest.cpp
+++ b/llvm/unittests/Support/YAMLIOTest.cpp
@@ -1298,7 +1298,7 @@ TEST(YAMLIO, TestScalarAfterBlockScalar) {
- block_scalac: |
AA
BB
-scalar: a
+ scalar: a
...
)");
}
|
You can reopen pull requests |
Test has merge conflict |
I try to reopen it but failed.
I will reland previous PR and re-run the test |
Test failures look real |
This change: ``` commit a80aad2 Author: Congcong Cai <[email protected]> Date: Thu Mar 27 02:16:27 2025 +0800 [YAML] fix output incorrect format for block scalar string (llvm#132897) ``` caused emission of empty lines to removed in some cases. Which broke the tests. This patch updates the test. rdar://148048779
This change: ``` commit a80aad2 Author: Congcong Cai <[email protected]> Date: Thu Mar 27 02:16:27 2025 +0800 [YAML] fix output incorrect format for block scalar string (llvm#132897) ``` caused emission of empty lines to removed in some cases. Which broke the tests. This patch updates the test. rdar://148048779
After outputting block scalar string, the indent will be wrong.
This patch fixes Padding after block scalar string to ensure the correct format of yaml.
The new added ut will fail in main.