20 #include "llvm/Support/raw_ostream.h" 22 using namespace clang;
26 class TraversalDumper :
public Checker< check::BranchCondition,
28 check::EndFunction > {
30 void checkBranchCondition(
const Stmt *Condition, CheckerContext &C)
const;
31 void checkBeginFunction(CheckerContext &C)
const;
32 void checkEndFunction(
const ReturnStmt *RS, CheckerContext &C)
const;
36 void TraversalDumper::checkBranchCondition(
const Stmt *Condition,
37 CheckerContext &C)
const {
42 const ParentMap &Parents = C.getLocationContext()->getParentMap();
50 llvm::outs() << C.getSourceManager().getSpellingLineNumber(Loc) <<
" " 54 void TraversalDumper::checkBeginFunction(CheckerContext &C)
const {
55 llvm::outs() <<
"--BEGIN FUNCTION--\n";
58 void TraversalDumper::checkEndFunction(
const ReturnStmt *RS,
59 CheckerContext &C)
const {
60 llvm::outs() <<
"--END FUNCTION--\n";
63 void ento::registerTraversalDumper(CheckerManager &mgr) {
64 mgr.registerChecker<TraversalDumper>();
67 bool ento::shouldRegisterTraversalDumper(
const LangOptions &LO) {
74 class CallDumper :
public Checker< check::PreCall,
77 void checkPreCall(
const CallEvent &Call, CheckerContext &C)
const;
78 void checkPostCall(
const CallEvent &Call, CheckerContext &C)
const;
82 void CallDumper::checkPreCall(
const CallEvent &Call, CheckerContext &C)
const {
83 unsigned Indentation = 0;
91 llvm::outs().indent(Indentation);
92 Call.dump(llvm::outs());
95 void CallDumper::checkPostCall(
const CallEvent &Call, CheckerContext &C)
const {
96 const Expr *CallE = Call.getOriginExpr();
100 unsigned Indentation = 0;
108 llvm::outs().indent(Indentation);
109 if (Call.getResultType()->isVoidType())
110 llvm::outs() <<
"Returning void\n";
112 llvm::outs() <<
"Returning " << C.getSVal(CallE) <<
"\n";
115 void ento::registerCallDumper(CheckerManager &mgr) {
116 mgr.registerChecker<CallDumper>();
119 bool ento::shouldRegisterCallDumper(
const LangOptions &LO) {
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
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.