[PATCH] D74541: [Analyzer] Use note tags to track iterator increments and decrements

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 23 19:37:02 PDT 2020


NoQ added inline comments.
Herald added a subscriber: ASDenysPetrov.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:489-490
+    StringRef ChangeText =
+      ((Op == OO_Plus || Op == OO_PlusEqual) != (ChangeVal <= 0)) ?
+      "incremented" : "decremented";
+    const NoteTag *ChangeTag = getChangeTag(C, ChangeText, ItE,
----------------
baloghadamsoftware wrote:
> NoQ wrote:
> > NoQ wrote:
> > > Can we assert out the `ChangeVal == 0` case or make a better message for it (`"unchanged"` or something like that)?
> > Another important thing to do here is to track the RHS value via `trackExpressionValue()`. I.e., why do we think that iterator is incremented by 1 and not by 2?
> I agree, that is important, but where should I call it? This is the modeling checker, which models the increments and the decrements, but `trackExpressionValue()` can only be invoked for bug reports. Should I put it into the `NoteTag` lambda?
Yup, it should be possible to invoke `trackExpressionValue()`, and generally attach more visitors, inside a `NoteTag`.


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

https://reviews.llvm.org/D74541





More information about the cfe-commits mailing list