[all-commits] [llvm/llvm-project] 4849d5: [clang] Warn [[clang::lifetimebound]] misusages on...

Maksim Ivanov via All-commits all-commits at lists.llvm.org
Tue Dec 3 02:10:32 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4849d593ab07c47f9f520bea636f62d159d57006
      https://github.com/llvm/llvm-project/commit/4849d593ab07c47f9f520bea636f62d159d57006
  Author: Maksim Ivanov <emaxx at google.com>
  Date:   2024-12-03 (Tue, 03 Dec 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaType.cpp
    M clang/test/SemaCXX/attr-lifetimebound.cpp

  Log Message:
  -----------
  [clang] Warn [[clang::lifetimebound]] misusages on types (#118281)

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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list