[all-commits] [llvm/llvm-project] 5d82cb: [clang-format] @lefticus just taught the world how...
MyDeveloperDay via All-commits
all-commits at lists.llvm.org
Tue May 19 08:51:17 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 5d82cb3c3a6af8d12b87bcbdc6abd3b7f4b01652
https://github.com/llvm/llvm-project/commit/5d82cb3c3a6af8d12b87bcbdc6abd3b7f4b01652
Author: mydeveloperday <mydeveloperday at gmail.com>
Date: 2020-05-19 (Tue, 19 May 2020)
Changed paths:
M clang/lib/Format/UnwrappedLineParser.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list