[PATCH] D124674: [analyzer] Indicate if a parent state is infeasible

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 03:53:05 PDT 2022


martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp:51
+    ProgramStateRef StFalse = assume(State, Cond, false);
+    if (!StFalse) { // both infeasible
+      ProgramStateRef Infeasible = State->cloneAsInfeasible();
----------------
steakhal wrote:
> Should we mark this `LLVM_UNLIKELY(cond)`?
> I would expect this function to be quite hot, and infeasible states rare.
> 
> Could we measure this one?
Yes, it could be.

Let me come back with some measurement results soon. I am going to use llvm statistics macros to measure this, but that makes sense on top of D124758


================
Comment at: clang/test/Analysis/sink-infeasible.c:37-48
+  /* The BASELINE passes these checks ('wrning' is used to avoid lit to match)
+  // The parent state is already infeasible, look at this contradiction:
+  clang_analyzer_eval(b > 0);  // expected-wrning{{FALSE}}
+  clang_analyzer_eval(b <= 0); // expected-wrning{{FALSE}}
+  // Crashes with expensive checks.
+  if (b > 0) {
+    clang_analyzer_warnIfReached(); // no-warning, OK
----------------
steakhal wrote:
> You could use a non-default check prefix.
No I can't, because this test code in the comment is meaningful only in the baseline, I cannot run both clang versions from lit.

So, actually there is no RUN line for these, it is here only to demonstrate what happens in the baseline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124674



More information about the cfe-commits mailing list