https://github.com/Erich-Reitz closed
https://github.com/llvm/llvm-project/pull/94776
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Erich-Reitz wrote:
> This patch formats
>
> ```
> void f() {
> if (foo)
> bar(); // Comment
> #if BAZ
> baz();
> #endif
> }
> ```
>
> to
>
> ```
> void f() {
> if (foo)
> bar();
> // Comment
> #if BAZ
> baz();
> #endif
> }
> ```
>
> The trailing comment shouldn't be wr
@@ -796,6 +796,44 @@ TEST_F(FormatTestComments,
ParsesCommentsAdjacentToPPDirectives) {
format("namespace {}\n /* Test */#define A"));
}
+TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) {
+ verifyFormat("void f() {\n"
+
https://github.com/Erich-Reitz updated
https://github.com/llvm/llvm-project/pull/94776
>From 6c910c8b40be79e3d573f6953860f60ebd27b39f Mon Sep 17 00:00:00 2001
From: Erich Reitz
Date: Fri, 7 Jun 2024 13:04:33 -0400
Subject: [PATCH 1/6] delay flushing comments before ifdef after braceless if;
al
@@ -796,6 +796,24 @@ TEST_F(FormatTestComments,
ParsesCommentsAdjacentToPPDirectives) {
format("namespace {}\n /* Test */#define A"));
}
+
+TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) {
+ EXPECT_EQ("void f() {\n"
https://github.com/Erich-Reitz updated
https://github.com/llvm/llvm-project/pull/94776
>From 6c910c8b40be79e3d573f6953860f60ebd27b39f Mon Sep 17 00:00:00 2001
From: Erich Reitz
Date: Fri, 7 Jun 2024 13:04:33 -0400
Subject: [PATCH 1/5] delay flushing comments before ifdef after braceless if;
al
https://github.com/Erich-Reitz updated
https://github.com/llvm/llvm-project/pull/94776
>From 6c910c8b40be79e3d573f6953860f60ebd27b39f Mon Sep 17 00:00:00 2001
From: Erich Reitz
Date: Fri, 7 Jun 2024 13:04:33 -0400
Subject: [PATCH 1/4] delay flushing comments before ifdef after braceless if;
al
https://github.com/Erich-Reitz created
https://github.com/llvm/llvm-project/pull/94776
Addresses issue #45002.
When `readToken()` sees a preprocessor directive, it eagerly flushes the
comments. This changes the behavior if it is within a braceless block.
Keeps behavior of
```
void f() {