Skip to content
Snippets Groups Projects
Commit f3e426b2 authored by Jordan Rose's avatar Jordan Rose
Browse files

[analyzer] Print return values from debug.DumpCalls checker.

Debug utility only, no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177649 91177308-0d34-0410-b5e6-96231b3b80d8
parent 7c22cf34
No related branches found
No related tags found
No related merge requests found
...@@ -61,9 +61,11 @@ void ento::registerTraversalDumper(CheckerManager &mgr) { ...@@ -61,9 +61,11 @@ void ento::registerTraversalDumper(CheckerManager &mgr) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace { namespace {
class CallDumper : public Checker< check::PreCall > { class CallDumper : public Checker< check::PreCall,
check::PostCall > {
public: public:
void checkPreCall(const CallEvent &Call, CheckerContext &C) const; void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
}; };
} }
...@@ -80,6 +82,26 @@ void CallDumper::checkPreCall(const CallEvent &Call, CheckerContext &C) const { ...@@ -80,6 +82,26 @@ void CallDumper::checkPreCall(const CallEvent &Call, CheckerContext &C) const {
Call.dump(llvm::outs()); Call.dump(llvm::outs());
} }
void CallDumper::checkPostCall(const CallEvent &Call, CheckerContext &C) const {
const Expr *CallE = Call.getOriginExpr();
if (!CallE)
return;
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);
if (Call.getResultType()->isVoidType())
llvm::outs() << "Returning void\n";
else
llvm::outs() << "Returning " << C.getSVal(CallE) << "\n";
}
void ento::registerCallDumper(CheckerManager &mgr) { void ento::registerCallDumper(CheckerManager &mgr) {
mgr.registerChecker<CallDumper>(); mgr.registerChecker<CallDumper>();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment