[PATCH] D124918: [clang-tidy] Add a new check for non-trivial unused variables.

Andy Soffer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 06:56:29 PDT 2022


asoffer added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/performance/UnusedNoSideEffectCheck.cpp:90
+    if (!Op->isAssignmentOp()) {
+      markSideEffectFree(Op->getRHS());
+    }
----------------
Perhaps I'm not understanding precisely what `markSideEffectFree` means, but this doesn't seem right to me:

```
int *data = ...;
auto getNextEntry = [&] () -> int& { return *++data; };
int n = (getNextDataEntry() + 17); // We can't mark RHS as side-effect free.
*data = n;
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124918/new/

https://reviews.llvm.org/D124918



More information about the cfe-commits mailing list