[PATCH] D64991: [analyzer][WIP] Implement a primitive reaching definitions analysis
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 29 21:19:34 PDT 2019
xazax.hun added inline comments.
================
Comment at: clang/include/clang/Analysis/Analyses/ReachingDefinitions.h:30
+ };
+ const VarDecl *Var;
+ CFGBlock::ConstCFGElementRef E;
----------------
In the future we might also want to reason about `FieldDecl`s.
================
Comment at: clang/include/clang/Analysis/Analyses/ReachingDefinitions.h:50
+ bool operator()(Definition Lhs, Definition Rhs) {
+ return Lhs.Var < Rhs.Var;
+ }
----------------
Is it safe to omit the Kind from the comparisons?
================
Comment at: clang/lib/Analysis/ReachingDefinitions.cpp:61
+ auto AssignmentM =
+ binaryOperator(isAssignmentOperator(),
+ hasLHS(declRefExpr(to(varDecl().bind("var")))))
----------------
Will this work if the LHS is not directly a declrefexpr?
E.g.:
```
(a, b) = 5;
```
Or more fun cases:
```
(cond ? a : b) = 5;
```
================
Comment at: clang/lib/Analysis/ReachingDefinitions.cpp:102
+ }
+ }
+
----------------
What about the non-const arguments of calls, and indirect writes through pointers? Even if you plan not to handle some of these, I prefer to have a TODO for these the appropriate places as soon as possible.
================
Comment at: clang/lib/Analysis/ReachingDefinitions.cpp:104
+
+ return Ret;
+}
----------------
There are non-assignment operators too, like operator++. You might want to consider them as definitions too.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64991/new/
https://reviews.llvm.org/D64991
More information about the cfe-commits
mailing list