[clang] clang::drop attribute (PR #204318)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 06:18:00 PDT 2026


erichkeane wrote:

I hate to pile on, but I think this isn't a sound design for an attribute (and also strongly dislike the name).  

It seems what you're looking for is some way to invalidate a variable statically. It does become fairly unsound thanks to control flow, unless you decide that :

```
int x;
if (a)
  drop_func(x);
...
if (!a)
  bar(x); // prohibited
```

Is an acceptable prohibition.  Thats just not control flow the FE can do (though, bugprone tests through tidy/etc are better about that).

But there is a VERY good reason that we have use-after-move where it is: because that is the most sound place to implement this.

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


More information about the cfe-commits mailing list