summaryrefslogtreecommitdiff
path: root/clang/unittests/Format/FormatTestComments.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTestComments.cpp')
-rw-r--r--clang/unittests/Format/FormatTestComments.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp
index d2baace6a7d8..3e75707a9fae 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -1087,6 +1087,36 @@ TEST_F(FormatTestComments, KeepsLevelOfCommentBeforePPDirective) {
Style);
}
+TEST_F(FormatTestComments, CommentsBetweenUnbracedBodyAndPPDirective) {
+ verifyFormat("{\n"
+ " if (a)\n"
+ " f(); // comment\n"
+ "#define A\n"
+ "}");
+
+ verifyFormat("{\n"
+ " while (a)\n"
+ " f();\n"
+ "// comment\n"
+ "#define A\n"
+ "}");
+
+ verifyNoChange("{\n"
+ " if (a)\n"
+ " f();\n"
+ " // comment\n"
+ "#define A\n"
+ "}");
+
+ verifyNoChange("{\n"
+ " while (a)\n"
+ " if (b)\n"
+ " f();\n"
+ " // comment\n"
+ "#define A\n"
+ "}");
+}
+
TEST_F(FormatTestComments, SplitsLongLinesInComments) {
// FIXME: Do we need to fix up the " */" at the end?
// It doesn't look like any of our current logic triggers this.