[cfe-dev] [StaticAnalyzer]: Cant get my checker to output
funceval
funceval at gmail.com
Wed Sep 28 09:48:52 PDT 2011
Hi,
How do I find out if my checker has run or not? There doesn't seem to be any
option in scan-build that tells us which checkers were run. I tried printing
to std::cout, std::cerr but nothing got printed. I tried generating a bug
report but that didn't get generated either. But my checker does show up in
the list of checkers when I run scan-build. I have even entered the details
in Checkers.td.
Here is what I have tried far:
namespace {
class ConstantConditionChecker : public
Checker<check::PostStmt<IfStmt> >{
mutable llvm::OwningPtr<BuiltinBug> BT;
public:
void checkPostStmt(const IfStmt *ifStmt, CheckerContext
&C) const;
};
}
void ConstantConditionChecker::checkPostStmt(const IfStmt *ifStmt,
CheckerContext &C) const
{
ASTContext& astContext = C.getASTContext();
std::string sbuf;
llvm::raw_string_ostream Out(sbuf);
ifStmt->getCond()->printPretty(Out, NULL,
PrintingPolicy(astContext.getLangOptions()));
std::cerr << Out.str() << std::endl;
std::cout << "Hello\n" << std::endl;
std::cerr << "Hello cerr" << std::endl;
if (!BT)
BT.reset(new BuiltinBug(Out.str().c_str()));
BugReport* R = new BugReport(*BT, BT->getDescription(),
C.getPredecessor());
R->addRange(ifStmt->getSourceRange());
C.EmitReport(R);
}
void ento::registerConstantConditionChecker(CheckerManager &mgr) {
mgr.registerChecker<ConstantConditionChecker>();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110928/ff36e0de/attachment.html>
More information about the cfe-dev
mailing list