[clang-format] [PR45639] clang-format splits up the brackets of C++17 attribute ...
authormydeveloperday <mydeveloperday@gmail.com>
Thu, 7 May 2020 20:57:14 +0000 (21:57 +0100)
committermydeveloperday <mydeveloperday@gmail.com>
Thu, 7 May 2020 21:00:04 +0000 (22:00 +0100)
commit5a4ddbd69db2b0e09398214510501d0e59a0c30b
tree3a3fd1474b87500c04170e64d55040e56c06178e
parent6227f021ad400cc604ca2d15d3639eabfd66a2d9
[clang-format] [PR45639] clang-format splits up the brackets of C++17 attribute [[ ]] when used with the first parameter

Summary:
https://bugs.llvm.org/show_bug.cgi?id=45639

clang-format incorrectly splits the `[[` in a long argument list

```
void SomeLongClassName::ALongMethodNameInThatClass([[maybe_unused]] const shared_ptr<ALongTypeName>& argumentNameForThat
LongType) {

}
```

becomes

```
void SomeLongClassName::ALongMethodNameInThatClass([
    [maybe_unused]] const shared_ptr<ALongTypeName> &argumentNameForThatLongType) {

}
```

leaving one `[` on the previous line

For a function with just 1 very long argument, clang-format chooses to split between the `[[`,

This revision prevents the slip between the two `[` and the second `[`

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79401
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp