Escapes replacement text when exporting to yaml and unescapes when importing from yaml.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/unittests/Tooling/ReplacementsYamlTest.cpp | ||
---|---|---|
68 | Can this ever be false. Does execution of a test case stop once an ASSERT_EQ fails |
clang/lib/Tooling/ReplacementsYaml.cpp | ||
---|---|---|
22 ↗ | (On Diff #249875) | Just so I have asked ;-) |
clang/unittests/Tooling/ReplacementsYamlTest.cpp | ||
55 | I think it would be worthwhile to test other characters as well. | |
68 | Yes, assert stops the test case. After the assert you can safely assume they are identical. | |
76 | I assume this kind of test would have been green even without your change? Or would it fail? |
- Extend tests
clang/lib/Tooling/ReplacementsYaml.cpp | ||
---|---|---|
22 ↗ | (On Diff #249875) | You need to escape the escape character to avoid ambiguity when unescaping later Say the code has the raw string which is \ followed by n. it would be escaped as \n. |
clang/unittests/Tooling/ReplacementsYamlTest.cpp | ||
55 | I have added all the c++ escape characters apart from \' as that is handled in the yaml string parser anyway and \" as that seems to be ignore anyway | |
76 | Yes this should've passed before however the issue was one more of readability. Things like the old double newline just look confusing whereas every programmer knows that '\n' is code for newline. |
Fine for me. Fixes newline bug in https://bugs.llvm.org/show_bug.cgi?id=45150.
However I don't have "review privileges" here.
I think it would be worthwhile to test other characters as well.
50% of that would be purely for documentation purposes. What would happen when you escape \x and unescape \\x?