[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 12:05:11 PDT 2020


MaskRay added inline comments.


================
Comment at: clang/lib/Analysis/UninitializedValues.cpp:676
+  Value v = vals[vd];
+  if (isUninitialized(v))
+    handler.handleConstRefUseOfUninitVariable(vd, getUninitUse(ex, vd, v));
----------------
This should use isAlwaysUninit. I fixed it in 7096e04a6831d4668c39b388ccd166f84de69191

Otherwise there are multiple false positives in stage2 build of llvm-project, e.g.

```
if (a < 42)
  var = 1;
if (a < 42)
  const_ref_use(var);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79895





More information about the cfe-commits mailing list