diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-07-10 23:56:23 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-07-10 23:56:23 +0000 |
commit | 8889cf008d850f22d60f74f502486dc239ab6903 (patch) | |
tree | 83990e933291aadec5df415d119cf413486e58f2 /clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp | |
parent | 6cd16c5152afcf00b3097d1326301e84dae55c33 (diff) | |
download | bcm5719-llvm-8889cf008d850f22d60f74f502486dc239ab6903.tar.gz bcm5719-llvm-8889cf008d850f22d60f74f502486dc239ab6903.zip |
[analyzer] Add debug.DumpCalls, which prints out any CallEvents it sees.
This is probably not so useful yet because it is not path-sensitive, though
it does try to show inlining with indentation.
This also adds a dump() method to CallEvent, which should be useful for
debugging.
llvm-svn: 160030
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp index d0479d45194..ed6187de9cc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/TraversalChecker.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This checker prints branch statements to llvm::outs as they are encountered. -// This lets us see exactly how the ExprEngine is traversing the graph. +// These checkers print various aspects of the ExprEngine's traversal of the CFG +// as it builds the ExplodedGraph. // //===----------------------------------------------------------------------===// #include "ClangSACheckers.h" @@ -16,6 +16,7 @@ #include "clang/AST/StmtObjC.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/Calls.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" using namespace clang; @@ -55,3 +56,29 @@ void TraversalDumper::checkEndPath(CheckerContext &C) const { void ento::registerTraversalDumper(CheckerManager &mgr) { mgr.registerChecker<TraversalDumper>(); } + +//------------------------------------------------------------------------------ + +namespace { +class CallDumper : public Checker< check::PreCall > { +public: + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; +}; +} + +void CallDumper::checkPreCall(const CallEvent &Call, CheckerContext &C) const { + unsigned Indentation = 0; + for (const LocationContext *LC = C.getLocationContext()->getParent(); + LC != 0; LC = LC->getParent()) + ++Indentation; + + // It is mildly evil to print directly to llvm::outs() rather than emitting + // warnings, but this ensures things do not get filtered out by the rest of + // the static analyzer machinery. + llvm::outs().indent(Indentation); + Call.dump(llvm::outs()); +} + +void ento::registerCallDumper(CheckerManager &mgr) { + mgr.registerChecker<CallDumper>(); +} |