aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests
diff options
context:
space:
mode:
authorowenca <owenpiano@gmail.com>2022-07-14 01:05:45 -0700
committerowenca <owenpiano@gmail.com>2022-07-14 15:19:57 -0700
commit6ab7307177c336d7ca5910fc434c012f35245fd1 (patch)
tree37f762729d66da121b311e9057977189774fbd67 /clang/unittests
parent5492b71db3c4722afa39f7073996e9b5fb166d00 (diff)
downloadllvm-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.cpp11
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);