[clang] [Clang][C++23] Implement P1774R8: Portable assumptions (PR #81014)

via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 27 09:51:41 PST 2024


Sirraide wrote:

> I think your suggestion is sensible, though I'm equally as OK with just making the standard attribute ONLY spellable as `[[assume]]` (and leaving the other attribute alone).

That would also be an option yeah. Only somewhat related, this diagnostic probably needs to be updated:
```c++
test.cc:2:4: error: 'assume' attribute cannot be applied to a statement
    2 |         [[clang::assume(3)]];
      |           ^                 ~
```
Because ‘'assume' attribute cannot be applied to a statement’ is just outright confusing now that `[[assume]]` exists and *has* to be applied to a statement. So if we keep `[[clang::assume]]` as-is, we should probably add something along the lines of ‘did you mean `[[assume]]` instead of `[[clang::assume]]`’.

Also, I just noticed that `[[clang::assume]]` apparently only appertains to function declarations, where `[[assume]]` isn’t allowed anyway, so I think distinguishing between the two is even less of a problem than I at least thought. I suppose the only question now is whether `[[clang::assume]]` should be treated like `[[assume]]` if it’s not applied to a function declaration?

https://github.com/llvm/llvm-project/pull/81014


More information about the cfe-commits mailing list