llvm-project
4f69f457 - (reland) [clang] Warn [[clang::lifetimebound]] misusages on types (#118501)

Commit
302 days ago
(reland) [clang] Warn [[clang::lifetimebound]] misusages on types (#118501) This relands #118281 as-is, after it got reverted in commit 356df2dd72e8299b5de58e9390283110c19f7c76. The reland can go in after we fixed some downstream codebases that had incorrectly placed attributes. Original commit description: > Emit the "cannot be applied to types" warning instead of silently ignoring the attribute when it's attempted to be used on a type (instead of a function argument or the function definition). > > Before this commit, the warning has been printed when the attribute was (mis)used on a decl-specifier, but not in other places in a declarator. > > Examples where the warning starts being emitted with this commit: > > ``` > int * [[clang::lifetimebound]] x; > > void f(int * [[clang::lifetimebound]] x); > > void g(int * [[clang::lifetimebound]]); > ``` > > Note that the last example is the case of an unnamed function parameter. While in theory Clang could've supported the `[[clang::lifetimebound]]` analysis for unnamed parameters, it doesn't currently, so the commit at least makes the situation better by highlighting this as a warning instead of a silent ignore - which was reported at #96034.
Author
Parents
Loading