[PATCH] D67156: [Analyzer] Debug Checkers for Container and Iterator Inspection

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 17:07:36 PDT 2019


NoQ added a comment.

Yup, thanks, this is really nice!



================
Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:243-244
+                                  Getter get) const;
+  void analyzerContainerBegin(const CallExpr *CE, CheckerContext &C) const;
+  void analyzerContainerEnd(const CallExpr *CE, CheckerContext &C) const;
+  template <typename Getter>
----------------
We usually define such getters for stuff that the programmer cannot obtain otherwise during normal program execution. These two functions look like they're probably equivalent to normal `.begin()` and `.end()` calls. I don't really object but do we really ever need them other than for testing the trivial implementations of `.begin()` and `.end()`?


================
Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1659-1660
+    Handler = llvm::StringSwitch<FnCheck>(C.getCalleeName(CE))
+      .Case("clang_analyzer_container_begin",
+            &IteratorChecker::analyzerContainerBegin)
+      .Case("clang_analyzer_container_end",
----------------
`CallDescriptionMap` please? ^.^


================
Comment at: test/Analysis/iterator-inspection.cpp:41-42
+
+  clang_analyzer_dump(&v0); //expected-warning{{&v0}}
+  clang_analyzer_dump(clang_analyzer_iterator_container(b0)); //expected-warning{{&v0}}
+}
----------------
Slightly more robust: `clang_analyzer_eval(clang_analyzer_iterator_container(b0) == &v0); // expected-warning{{TRUE}}`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D67156





More information about the cfe-commits mailing list