diff options
author | owenca <owenpiano@gmail.com> | 2022-07-14 01:05:45 -0700 |
---|---|---|
committer | owenca <owenpiano@gmail.com> | 2022-07-14 15:19:57 -0700 |
commit | 6ab7307177c336d7ca5910fc434c012f35245fd1 (patch) | |
tree | 37f762729d66da121b311e9057977189774fbd67 /clang/unittests | |
parent | 5492b71db3c4722afa39f7073996e9b5fb166d00 (diff) | |
download | llvm-6ab7307177c336d7ca5910fc434c012f35245fd1.zip llvm-6ab7307177c336d7ca5910fc434c012f35245fd1.tar.gz llvm-6ab7307177c336d7ca5910fc434c012f35245fd1.tar.bz2 |
[clang-format] Fix invalid-code-generation by RemoveBracesLLVM
When removing an r_brace that is the first token of an annotated line, if the
line above ends with a line comment, clang-format generates invalid code by
merging the tokens after the r_brace into the line comment.
Fixes #56488.
Differential Revision: https://reviews.llvm.org/D129742
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e506d0d..ba07584 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -25742,6 +25742,17 @@ TEST_F(FormatTest, RemoveBraces) { Style); verifyFormat("if (a) {\n" + " if (b)\n" + " c = 1; // comment\n" + "}", + "if (a) {\n" + " if (b) {\n" + " c = 1; // comment\n" + " }\n" + "}", + Style); + + verifyFormat("if (a) {\n" "Label:\n" "}", Style); |