[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 05:53:53 PDT 2021
darwin marked 2 inline comments as done.
darwin added inline comments.
================
Comment at: clang/unittests/Format/FormatTest.cpp:280
+ "}",
+ CustomStyle));
+ EXPECT_EQ("/* something */ namespace N\n"
----------------
MyDeveloperDay wrote:
> I'm not sure I understand this.. why is this not
>
> ```
> namespace N
> {
> int i;
> }
> ```
Because a namespace is different than a class or struct.
Please try this with chang-format:
```
darwin at Darwins-iMac Desktop % cat a.cpp
namespace N {
int i;
}
darwin at Darwins-iMac Desktop % clang-format a.cpp -style="{BasedOnStyle: google}"
namespace N {
int i;
}
```
As you can see, clang-format removes the extra lines but still keeps one line at the beginning and the end of the namespace. This is the original behavior, I think it is very reasonable.
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