This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] add support for branch attribute macros
ClosedPublic

Authored by MyDeveloperDay on Dec 16 2021, 1:55 AM.

Details

Summary

https://github.com/llvm/llvm-project/issues/49184

clang-format doesn't handle the use of AttributeMacros where [[unlikely]] / [[likely]] could be used in if statements

This was nor covered in the original commit {D80144: [clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot to teach clang-format}

if (StartIndex == End)
    BRANCH_UNLIKELY
return npos;

Give better support via

if (StartIndex == End) [[unlikely]]
  return npos;

if (StartIndex == End) [[unlikely]] {
  return npos;
}

if (StartIndex == End) UNLIKELY
  return npos;

if (StartIndex == End) UNLIKELY {
  return npos;
}

Fixes #49184

Diff Detail

Event Timeline

MyDeveloperDay requested review of this revision.Dec 16 2021, 1:55 AM
MyDeveloperDay created this revision.
MyDeveloperDay edited the summary of this revision. (Show Details)Dec 16 2021, 1:58 AM
curdeius accepted this revision.Dec 16 2021, 3:11 AM

LGTM!

Tested locally.
Has Bolt landed? It seems that the CI adds bolt as the project but it isn't recognized...

This revision is now accepted and ready to land.Dec 16 2021, 3:11 AM
owenpan accepted this revision.Dec 16 2021, 3:46 AM
This revision was landed with ongoing or failed builds.Dec 16 2021, 12:36 PM
This revision was automatically updated to reflect the committed changes.