[PATCH] D80144: [clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot to teach clang-format

Roel Vercammen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 20 04:33:02 PST 2022


Roelio81 added a comment.
Herald added a project: All.

This change also has impact which was undesired on our code base as it now considers all attributes to be "bound" to the if-expression rather than to the if-body.
For example, we had this in our code base

  if (condition)
     [[maybe_unused]] auto result = x->setValue(0.0);

This became the following after upgrading from clang 10:

  if (condition) [[maybe_unused]] 
     auto result = x->setValue(0.0);

The [[maybe_unused]] is actually referring to the result variable, hence I think it makes more sense to have it on the second line.
We worked around the issue by adding curly braces, i.e.,

  if (condition)
  {
     [[maybe_unused]] auto result = x->setValue(0.0);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80144



More information about the cfe-commits mailing list