[PATCH] D42552: [analyzer] dump() environment frame-by-frame.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 25 12:10:13 PST 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

Like this:

  Expressions by stack frame:
  #0 Calling bar at line 9
  (0x7fbe2a60ea10,0x7fbe2b86ca30) x : 1 S32b
  #1 Calling foo
  (0x7fbe2a60e2e0,0x7fbe2b86cc98) bar : &code{bar}
  (0x7fbe2a60e2e0,0x7fbe2b86cce0) x : 0 S32b

Or in exploded graph:

F5784469: Frames.png <https://reviews.llvm.org/F5784469>

This way it's instantly obvious which `x` is equal to `1` and which `x` is equal to `0`.

Additionally, the separate section for the backtrace is removed from the graphviz dumps, and the respective code is deduplicated with `LocationContext::dumpStack()` which is also used for crash dumps.

It might be not clear where is the current location context in some cases (or annoying to supply location context every time you want to dump the program state - it is not even necessarily available), so i made a simple auto-detection of the freshest location context in which the environment has at least one entry, which would be run unless the context is specified explicitly.

The dump is a bit weird for blocks, but nevertheless it represents how the analyzer currently works:

F5784474: Blocks.png <https://reviews.llvm.org/F5784474>


Repository:
  rC Clang

https://reviews.llvm.org/D42552

Files:
  include/clang/Analysis/AnalysisDeclContext.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  test/Analysis/crash-trace.c
  test/Analysis/expr-inspection.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42552.131492.patch
Type: text/x-patch
Size: 11062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180125/6dcc45bb/attachment.bin>


More information about the cfe-commits mailing list