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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 8 00:43:54 PDT 2021


MyDeveloperDay added a comment.

In D105479#2862819 <https://reviews.llvm.org/D105479#2862819>, @aaron.ballman wrote:

> Thank you for working on this!

So I looked into do what you suggested originally, but it became a little more involved, partially because you have to look inside the AttrbutedStmt but then getting the `{}` to cuddle the statement and not the attributes (and this means a lot more code has to be changed because you have to move the position of S to that statement so that you determine the correct place to put replacements, (and then this got way beyond my pay grade!)

So for this patch I was limiting it just to fixing the issue (that was actually incorrectly raised against #clang-format <https://reviews.llvm.org/tag/clang-format/> , hence why I'm here!)

I don't personally use the `[[likely]]` attributes yet so I wasn't completely sure of all the places it COULD be added.

For the case you raised I also don't believe it will do the correct thing,  https://godbolt.org/z/xb1qrTe3j    infact it will generate:

  if (b) {
     [[likely]]
     return;
  }

Use https://godbolt.org/z/YzrKzKoTe then add -fix to the clang-tidy Arguments (it will destroy your original source)

Which I wasn't sure if this is then still valid syntax? Although it may compile I couldn't really tell if it was then being ignored.


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