[clang-tools-extra] Extend bugprone-use-after-move check to handle std::optional::reset() and std::any::reset() (PR #114255)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 9 05:24:31 PST 2024


================
@@ -279,7 +281,7 @@ void UseAfterMoveFinder::getDeclRefs(
         if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
           // Ignore uses of a standard smart pointer that don't dereference the
           // pointer.
-          if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
+          if (Operator || !isStandardResettableOwner(DeclRef->getDecl())) {
----------------
5chmidti wrote:

Could you please add a test for the (e.g.) dereference?

```c++
// add T& operator&();
// ...

  {
    std::optional<A> opt;
    std::move(opt);
    auto val = *opt;
    (void)val;
  }
```

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


More information about the cfe-commits mailing list