Introduce a new function clang_analyzer_value. It emits a report that in turn prints a RangeSet or APSInt associated with SVal. If there is no associated value, prints n/a.
Diff Detail
Event Timeline
Looks great!
Maybe clang_analyzer_range() instead?
Please add documentation to https://clang.llvm.org/docs/analyzer/developer-docs/DebugChecks.html
clang/test/Analysis/print-ranges.cpp | ||
---|---|---|
2 | I suspect this test will crash when clang is built with Z3, because the Z3 constraint manager doesn't implement your new function yet. |
Thanks for the notes, @NoQ .
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.
Please add documentation to https://clang.llvm.org/docs/analyzer/developer-docs/DebugChecks.html
I'll do.
clang/test/Analysis/print-ranges.cpp | ||
---|---|---|
2 | Agree. Is it enough REQUIRES: no-z3 or to add #ifdef ANALYZER_CM_Z3? |
Constrained the test by adding llvm-lit REQUIRES command.
Documented a new function at https://clang.llvm.org/docs/analyzer/developer-docs/DebugChecks.html
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.
clang/test/Analysis/print-ranges.cpp | ||
---|---|---|
2 | That should be good. My personal tradition in such cases is to double-check that this doesn't disable the test entirely. |
Very good!
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.
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h | ||
---|---|---|
126 | printValue would be more general than printRange which is unique for the range based constraint manager. | |
clang/test/Analysis/print-ranges.cpp | ||
1 | Don't forget to pin the target/triple. |
Stick to name clang_analyzer_value.
Change function name from printRange to printValue.
Make description more precise in the documentation.
Closed with bc08c3cb7f8e797fee14e96eedd3dc358608ada3
clang/test/Analysis/print-ranges.cpp | ||
---|---|---|
1 | Why does this specific test need it? | |
2 | I added REQUIRES: z3 it prints Unsupported, then added REQUIRES: no-z3 and it passed. |
clang/test/Analysis/print-ranges.cpp | ||
---|---|---|
1 | I thought, the bit widths down below might change with different architectures and some build bots might break because of that. |
printValue would be more general than printRange which is unique for the range based constraint manager.