[clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot...
authormydeveloperday <mydeveloperday@gmail.com>
Tue, 19 May 2020 15:50:24 +0000 (16:50 +0100)
committermydeveloperday <mydeveloperday@gmail.com>
Tue, 19 May 2020 15:50:24 +0000 (16:50 +0100)
commit5d82cb3c3a6af8d12b87bcbdc6abd3b7f4b01652
treef4de1a5b5c25aac7dcd5b350bdde28e3fd1a31a6
parent575c59cf6a32889c5f1131af39e07bbdde27e8da
[clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot to teach clang-format

Summary:
https://twitter.com/lefticus/status/1262392152950288384?s=20

Jason Turner's (@lefticus) most recent C++ weekly explains the usage of [[likely]] and [[unlikely]] in an 'if/else' context in C++ 20

clang-format leaves the code a little messy afterwards..

```
if (argc > 5)
  [[unlikely]] {
    // ...
  }
else if (argc < 0)
  [[likely]] {
    // ...
  }
else
  [[likely]] {
    // ...
  }
```

try to improve the situation

```
if (argc > 5) [[unlikely]] {
  // ...
} else if (argc < 0) [[likely]] {
  // ...
} else [[likely]] {
  // ...
}
```

Reviewed By: JakeMerdichAMD

Subscribers: cfe-commits, lefticus

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D80144
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp