[PATCH] D105479: [clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with [[likely]] [[unlikely]]

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 7 12:45:05 PDT 2021


aaron.ballman added a comment.

Thank you for working on this!



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp:7-14
+  if (b) [[likely]] {
+    // CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+    return;
+  }
+  if (b) [[unlikely]] {
+    // CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+    return;
----------------
Can you also add tests that show we do the correct thing for:
```
if (b) [[likely]]
  return;
if (b) [[unlikely]]
  return;
```
where there were no braces involved? We should ensure that it wants to insert the braces after the attribute.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105479/new/

https://reviews.llvm.org/D105479



More information about the cfe-commits mailing list