[PATCH] D41151: [analyzer] Adding LoopContext and improve loop modeling

Peter Szecsi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 16:48:35 PST 2018

szepet added inline comments.

Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:28-46
 struct LoopState {
   enum Kind { Normal, Unrolled } K;
-  const Stmt *LoopStmt;
-  const LocationContext *LCtx;
-  unsigned maxStep;
-  LoopState(Kind InK, const Stmt *S, const LocationContext *L, unsigned N)
-      : K(InK), LoopStmt(S), LCtx(L), maxStep(N) {}
+  unsigned MaxStep;
+  LoopState(Kind InK, unsigned N) : K(InK), MaxStep(N) {}
NoQ wrote:
> Should the whole `LoopState` be reduced to a field(s) in `LoopContext`? It seems to make sense to me, unless we're planning to modify it in the middle of the loop.
I'm not sure about that. I mean, LoopContext is a general thing for all of the loops. It can easily happen that we modify the bound in the middle of the loop. Another thing what we keep track on if it is unrolled or not which is again something that we can decide to change in the middle of an iteration (e.g. it splits the state).

Yes, in our case MaxStep is not likely to change since we store loops that have a fix bound. (This could change in the future but maybe this is a too bold idea.)


More information about the cfe-commits mailing list