[clang] [clang-tools-extra] [llvm] User-defined annotations for clang-tidy analysis POC (PR #195054)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Fri May 8 08:44:38 PDT 2026


vbvictor wrote:

Hi, thank you for the proposal! Have you read similar thread in https://discourse.llvm.org/t/rfc-add-a-class-attribute-clang-null-after-move-for-use-after-move-analysis/89760?

I think from clang side, new annotation that is used only for analysis will be rejected due to very narrow scope.

I think we can reuse `clang::annotate` for this case and make something like:
```cpp
[[clang::annotate("analyze_as_class", "optional")]]
[[clang::annotate("analyze_as_method", "std::optional::has_value")]]
```

Or if we with to be more verbose and specific (up to discussion):

```cpp
[[clang::annotate("clang-tidy", "analyze_as_class", "optional")]]
[[clang::annotate("clang-tidy", "analyze_as_method", "optional::has_value")]]
```



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


More information about the cfe-commits mailing list