staffantj added a comment.

In D86559#2242586 <https://reviews.llvm.org/D86559#2242586>, @Mordante wrote:

> if(a)                      // Attribute not allowed on a declaration,
>
>   [[likely]] int i = 5;  // but I can't think about a good use-case
>                          // for this code.
>
> if(a) [[likely]] { // Good allowed on the compound statement
>
>     int i = 5;     // Now i seems to have a purpose
>   ...
>
> }

The use case for this becomes clearer when considering that the attribute that 
will be used 95% of the time is [[unlikely]]. You may have a constructor that 
you wish to ask the compiler to please, please, do not inline this, in a 
particular function, even if the rest of that function is either likely or 
neutral.

  if (a)
    [[unlikely]] expensive_class q{};

This could be the case if expensive_class held large static members, for 
instance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86559

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to