21 #include "llvm/Support/raw_ostream.h" 23 using namespace clang;
27 class TraversalDumper :
public Checker< check::BranchCondition,
29 check::EndFunction > {
31 void checkBranchCondition(
const Stmt *Condition, CheckerContext &C)
const;
32 void checkBeginFunction(CheckerContext &C)
const;
33 void checkEndFunction(
const ReturnStmt *RS, CheckerContext &C)
const;
37 void TraversalDumper::checkBranchCondition(
const Stmt *Condition,
38 CheckerContext &C)
const {
43 const ParentMap &Parents = C.getLocationContext()->getParentMap();
51 llvm::outs() << C.getSourceManager().getSpellingLineNumber(Loc) <<
" " 55 void TraversalDumper::checkBeginFunction(CheckerContext &C)
const {
56 llvm::outs() <<
"--BEGIN FUNCTION--\n";
59 void TraversalDumper::checkEndFunction(
const ReturnStmt *RS,
60 CheckerContext &C)
const {
61 llvm::outs() <<
"--END FUNCTION--\n";
64 void ento::registerTraversalDumper(CheckerManager &mgr) {
65 mgr.registerChecker<TraversalDumper>();
71 class CallDumper :
public Checker< check::PreCall,
74 void checkPreCall(
const CallEvent &Call, CheckerContext &C)
const;
75 void checkPostCall(
const CallEvent &Call, CheckerContext &C)
const;
79 void CallDumper::checkPreCall(
const CallEvent &Call, CheckerContext &C)
const {
80 unsigned Indentation = 0;
88 llvm::outs().indent(Indentation);
89 Call.dump(llvm::outs());
92 void CallDumper::checkPostCall(
const CallEvent &Call, CheckerContext &C)
const {
93 const Expr *CallE = Call.getOriginExpr();
97 unsigned Indentation = 0;
105 llvm::outs().indent(Indentation);
106 if (Call.getResultType()->isVoidType())
107 llvm::outs() <<
"Returning void\n";
109 llvm::outs() <<
"Returning " << C.getSVal(CallE) <<
"\n";
112 void ento::registerCallDumper(CheckerManager &mgr) {
113 mgr.registerChecker<CallDumper>();
Stmt - This represents one statement.
Stmt * getParent(Stmt *) const
Defines the Objective-C statement AST node classes.
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
const LocationContext * getParent() const
This represents one expression.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Encodes a location in the source.
Dataflow Directional Tag Classes.
Represents Objective-C's collection statement.