[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 22 22:40:32 PST 2019


Szelethus added a comment.

In D50488#1405094 <https://reviews.llvm.org/D50488#1405094>, @mgrang wrote:

> So I was able compile a couple of C++ code bases through csa-testbench. I built cppcheck and tinyxml2 without any problems. cppcheck has one invocation std::sort but the keys are not pointers whereas tinyxml2 does not use std::sort. I tried bitcoin, rtags, xerces but run into a lot of configure/build errors.


Thats great. How about LLVM+Clang? That'll be a pain in the butt to analyze, but is pretty great for testing. Also, did you clone rtags with the git option `--recursive`?



================
Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:97
 
+def NonDeterminismAlpha : Package<"nondeterminism">, ParentPackage<Alpha>;
+
----------------
Hmmm, okay, so your checker ks C++ exclusive I belive? How about making this checker reside in `alpha.cplusplus`? Rgard this one as more of a question.


================
Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:1
+//===------------------ PointerSortingChecker.cpp -------------------------===//
+//
----------------
Missing emacs thingie here?


================
Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:30
+// ID of a node at which the diagnostic would be emitted.
+const char *WarnAtNode = "sort";
+
----------------
I heard somewhere that LLVM::StringLiteral is used for global constexpr strings? Anyway, constexpr could be added here if I'm wrong sbout that :)


================
Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:110
+void ento::registerPointerSortingChecker(CheckerManager &Mgr) {
+  if (Mgr.getLangOpts().CPlusPlus)
+    Mgr.registerChecker<PointerSortingChecker>();
----------------
This is no longer needed, your checker wont be registered if the shouldRegister function returns false.


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

https://reviews.llvm.org/D50488





More information about the cfe-commits mailing list