[PATCH] D40809: [WIP] [analyzer] Dump counterexample traces as C programs

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 4 15:07:32 PST 2017


george.karpenkov created this revision.
Herald added subscribers: a.sidorin, szepet, xazax.hun.

This patch is work in progress, but has already shown itself to be useful in a few cases.

For large traces understanding the analyzer output can be painful, especially when arrows indicating the flow start to loop around.
This patch provides an alternative output method: simply iterate over all program points in a bug report, and dump them to the associated C statements (with program-line-based granularity).
In the ideal case (which we currently don't aim to get) the resulting program is a refinement of an input which goes through the indicated error path.
In the current case, it is a C-like visualization (as some statements are unexpectedly dropped, and some context is missing) of what the error path is.

Unresolved issues:

- I haven't found a way to run a visitor for all incoming reports, seems that each visitor has to attach a visitor manually. Maybe that functionality would have to be added.
- This needs to be behind a flag, still haven't thought of a good name.
- Always dumping to stderr is bad, this should go into a file, which should somehow get synced to the plist/html/stderr output.
- Stderr output might be confusing in presence of multiple reports, as the current code will dump all counterexamples first, and then will actually start showing the warnings.
- In the default driver mode, all counterexamples will be dumped twice (presumably because visitor is invoked for HTML and for PLIST output)


https://reviews.llvm.org/D40809

Files:
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40809.125426.patch
Type: text/x-patch
Size: 7019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171204/c8784a35/attachment.bin>


More information about the cfe-commits mailing list