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

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 10 03:51:05 PDT 2018


whisperity added inline comments.


================
Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:88
+
+  if (!II->getName().equals("sort"))
+    return;
----------------
Brrr... `equals`. StringRef has a `==` and `!=` operator which accepts string literals on the other side, which would result in a more concise code.

Also, this heuristic can be applied without extra changes (apart from those mentioned by NoQ and might be mentioned later by others) to other sorting functions, such as `std::stable_sort` and `std::stable_partition`. Perhaps it would be worthy to enable checking those functions too.


Repository:
  rC Clang

https://reviews.llvm.org/D50488





More information about the cfe-commits mailing list