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

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 9 14:47:18 PDT 2018


NoQ added a comment.

Hmm, this might make a good `optin.*` checker. Also i see that this is a pure AST-based checker; did you consider putting this into `clang-tidy`? Like, you shouldn't if you're not using `clang-tidy` yourself (it's a bit messy) but this is an option. Also we're actively using `ASTMatchers` in Analyzer checkers anyway these days because they're just shorter and easier to read and generally cool.



================
Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:91-100
+  const QualType IterTy = CE->getArg(0)->getType();
+  const RecordDecl *RD =
+    IterTy->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
+
+  if (RD->field_empty())
+    return;
+
----------------
This heuristic ("the argument of `std::sort` is //a class whose first field is of pointer type//") is quite wonky, do you have a plan on how to make it more precise?


Repository:
  rC Clang

https://reviews.llvm.org/D50488





More information about the cfe-commits mailing list