[PATCH] D129498: [analyzer] Add new function `clang_analyzer_value` to ExprInspectionChecker

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 14 08:05:47 PDT 2022


martong added a comment.

Very good!

In D129498#3650595 <https://reviews.llvm.org/D129498#3650595>, @NoQ wrote:

> In D129498#3647348 <https://reviews.llvm.org/D129498#3647348>, @ASDenysPetrov wrote:
>
>> In D129498#3644222 <https://reviews.llvm.org/D129498#3644222>, @NoQ wrote:
>>
>>> Maybe `clang_analyzer_range()` instead?
>>
>> This was its first name. I refused. First, because it emits concrete integers as well and moreover we can extend it for arrays or strings e.g. Second, the ranges is just an implementation detail and an actual thing we want to see is an associated value.
>
> Ok how about `clang_analyzer_constraint()`? A concrete value could be thought of as constraint, and so can be range, or anything else any exotic constraint managers may decide to dump.

We associate a value to a variable even if that is unconstrained. That value is the whole range of the variable's type. In this sense, I vote for `clang_analyzer_value`.



================
Comment at: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h:126
 
+  virtual void printRange(raw_ostream &Out, ProgramStateRef State,
+                          SymbolRef Sym) {}
----------------
`printValue` would be more general than `printRange` which is unique for the range based constraint manager.


================
Comment at: clang/test/Analysis/print-ranges.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config eagerly-assume=false -verify %s
+// REQUIRES: no-z3
----------------
Don't forget to pin the target/triple.


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

https://reviews.llvm.org/D129498



More information about the cfe-commits mailing list