[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 12 05:09:03 PST 2020


Szelethus added a comment.

Do we have a test where 2 containers are present but only one of them should be marked as interesting?

  void deref_end_after_pop_back(std::vector<int> &V, std::vector<int> &V2) {
    const auto i = --V.end();
    const auto i2 = --V2.end();
  
    V.pop_back();  // expected-note{{Container 'V' shrinked from the right by 1 position}}
    V2.pop_back(); // no-note
  
    *i; // expected-warning{{Past-the-end iterator dereferenced}}
        // expected-note at -1{{Past-the-end iterator dereferenced}}
  }



================
Comment at: clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp:95-103
+        const NoteTag *InterestingTag =
+          C.getNoteTag([Cont](BugReport &BR) -> std::string {
+              auto *PSBR = dyn_cast<PathSensitiveBugReport>(&BR);
+              if (PSBR) {
+                PSBR->markInteresting(Cont);
+              }
+              return "";
----------------
Aha, makes sense, when calling `clang_analyzer_container_end(V)`, we want to make the analyzer emit more information about `V` so its obviously interesting.


================
Comment at: clang/test/Analysis/container-modeling.cpp:35
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
----------------
I hate to be that guy, but this is quite ugly :). How about the handsome
```
//===--------------------------===//
// Container assignment tests.
//===--------------------------===//
```
But I don't insist, especially within the scope of this patch.


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

https://reviews.llvm.org/D73720





More information about the cfe-commits mailing list