[PATCH] D104044: [clang-format] Fix the issue that empty lines being removed at the beginning of namespace

Darwin Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 21 00:25:17 PDT 2021


darwin marked an inline comment as done.
darwin added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:281
+                   CustomStyle));
+  EXPECT_EQ("/* something */ namespace N\n"
+            "{\n"
----------------
MyDeveloperDay wrote:
> What does
> 
> ```
> namespace N  { /* comment */
> ```
> 
> or 
> 
> ```
> namespace N   /* comment */ {
> ```
> 
> do
It works fine: (with `-style="{BasedOnStyle: google, BreakBeforeBraces: Custom, BraceWrapping: {AfterNamespace: true}}"`)
```
namespace A /* comment */ { class B {} }

namespace A {/* comment */ class B {} }

namespace A { /* comment */


 class B {}


  }

namespace A/* comment */ {


 class B {}


  }
```
Is formatted like this:
```
namespace A /* comment */
{
class B {}
}  // namespace A

namespace A
{ /* comment */
class B {}
}  // namespace A

namespace A
{ /* comment */

class B {}

}  // namespace A

namespace A /* comment */
{

class B {}

}  // namespace A
```

I will update the test case too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104044/new/

https://reviews.llvm.org/D104044



More information about the cfe-commits mailing list