[PATCH] D15448: [analyzer] SVal Visitor.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 28 07:09:51 PST 2015
NoQ updated this revision to Diff 43683.
NoQ marked an inline comment as done.
NoQ added a comment.
An attempt on the .def-files.
The next step would probably be the `VisitChildren()` thing, and I'll see if it allows to refactor and simplify some code.
______
Forgot to answer: I guess there are a few minor-but-good things about the visitors in our case compared in-class methods (such as `dumpToStream()`):
1. Easy to develop incrementally - no need to put stubs into all subclasses for methods we didn't yet implement.
2. Easy to create incomplete visitors (eg. we want to visit only `SVal`'s that appear as `Store` values, and we won't ever see a `MemSpaceRegion` appear as a `Store` value)
3. Cover the whole sub-class with a single method (eg. `VisitTypedValueRegion()` covers all kinds of `TypedValueRegion`'s).
4. Easy to create checker-specific traversal methods - if a particular checker needs to visit the hierarchy, it's not forced to adjust all classes.
The question in what way the visitor is better than a recursive function with a very large switch is a bit more complicated (because a visitor essentially //is// a recursive function with a very large switch); only point 3 of the above still applies. With `VisitChildren()`, however, it becomes much more convenient.
Hmm. One more thing about `VisitChildren()`: Normally such method is re-implemented in every visitor easily using child iterators. We don't, however, have fully functional iterators for `SVal`/`SymExpr`/`MemRegion` children (only partial solutions like `symbol_begin()`..`symbol_end()`), and also such iterators would need to be polymorphic around these three classes (eg. a symbol-child of a region). In fact, i can make such polymorphic iterators, and that'd probably be a more generic solution.
http://reviews.llvm.org/D15448
Files:
docs/analyzer/DebugChecks.rst
include/clang/StaticAnalyzer/Checkers/SValExplainer.h
include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
include/clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h
include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
include/clang/StaticAnalyzer/Core/PathSensitive/Symbols.def
lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
test/Analysis/explain-svals.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15448.43683.patch
Type: text/x-patch
Size: 40798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151228/c74c56db/attachment-0001.bin>
More information about the cfe-commits
mailing list