| Issue |
53405
|
| Summary |
Bad formatting related to a variadic template and a compound statement
|
| Labels |
clang-format
|
| Assignees |
|
| Reporter |
mordante
|
I originally encountered a formatting issue in this file using a recent main build of clang-format
https://github.com/llvm/llvm-project/blob/ce368e1aa51f3d9f0a5f6ff0be3c02a9cf1e2d2e/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
Using the LLVM formatting style I can reproduce the issue with the following example
```
auto test = []<class... Args>(const Args &... args) {
{
(void) sizeof...(args);
(void) sizeof...(args);
}
};
```
which clang-format turns into
```
auto test_formatted =
[]<class... Args>(const Args &...args){{(void)sizeof...(args);
(void)sizeof...(args);
}
}
;
```
When the lambda doesn't have a variadic template there's no issue
```
auto test_non_variadic = []<class Args>(const Args &args) {
{
(void)sizeof(args);
(void)sizeof(args);
}
};
```
Two other works arounds are
```
auto test_using_if = []<class... Args>(const Args &...args) {
if (1) {
(void)sizeof...(args);
(void)sizeof...(args);
}
};
auto test_using_if_preprocessor = []<class... Args>(const Args &...args) {
#if 0
#endif
{
(void)sizeof...(args);
(void)sizeof...(args);
}
};
```
The expected output should be the same as/similar to the original provided example.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs