[PATCH] D114848: [Analysis] Ignore casts and unary ops for uninitialized values
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 6 11:59:14 PST 2021
nickdesaulniers added inline comments.
================
Comment at: clang/lib/Analysis/UninitializedValues.cpp:819-820
+ // semantic analysis passes.
+ while (isa<UnaryOperator>(Ex))
+ Ex = stripCasts(C, dyn_cast<UnaryOperator>(Ex)->getSubExpr());
+
----------------
Q: are there any unary operators that are not casts? For example isn't something like `-x` a unary negation operator? I worry that this could be an infinite loop as written.
If this fear is unfounded, then I think the code could be rewritten as:
```
while (const auto *UO = dyn_cast<UnaryOperator>(Ex))
Ex = stripCasts(C, UO->getSubExpr());
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114848/new/
https://reviews.llvm.org/D114848
More information about the cfe-commits
mailing list