Hi,<div><br></div><div>Thank you for replying. The problem is that clang is running some optimizations before running the analyzer. As a result, my if statement is being optimized out and because of that nothing gets printed. clang should not run optimizations when running in analyze mode otherwise it can't detect bugs in the original code. Do you agree?</div>

<div><br></div><div>Thanks,</div><div>Arjun<br><br><div class="gmail_quote">On Wed, Sep 28, 2011 at 11:19 AM, Anna Zaks <span dir="ltr"><<a href="mailto:ganna@apple.com">ganna@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div>Hello,</div><div><br></div><div><div>Check if your checker is properly registered. You can use the following command to view the registered checkers:</div>$ clang -cc1 -analyzer-checker-help<div>

Only some of them will get executed when scan-build is run (If you see your checker listed in scan-build output, it should be executed). </div><div><br></div><div>Are there if statements in your test program? You would see the output only when an if statement is processed.</div>

<div><br></div><div><div><div></div></div></div></div><div>While developing/debugging a checker, you can use the following command (this will execute only the specified checker):</div><div>$ clang -cc1 -analyze -analyzer-checker=core.StackAddressEscape input.cpp</div>

<div><br></div><div><div><div>You can print debug messages with:</div><div><span style="font-family:Monaco;font-size:11px">llvm::</span><span style="font-family:Monaco;font-size:11px"><span style="text-decoration:underline">errs</span></span><span style="font-family:Monaco;font-size:11px">()<<</span><span style="font-family:Monaco;font-size:11px"><span style="color:rgb(51, 68, 252)">"Hello"</span></span><span style="font-family:Monaco;font-size:11px">;</span></div>

<div><font face="Monaco"><span style="font-size:11px">llvm::outs()<<"Hello";<br></span></font><div><div></div></div></div></div></div><div><br></div><div>Cheers,</div><div>Anna.</div><div><div><div><div><div>

</div><div class="h5"><div><br></div><div>On Sep 28, 2011, at 9:48 AM, funceval wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5">Hi,<div><br></div><div>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. </div>



<div><br></div><div>Here is what I have tried far:</div><div><br></div><div><div>namespace {</div><div>          class ConstantConditionChecker : public Checker<check::PostStmt<IfStmt> >{</div><div>              mutable llvm::OwningPtr<BuiltinBug> BT;</div>



<div>          public:</div><div>                  void checkPostStmt(const IfStmt *ifStmt, CheckerContext &C) const;</div><div>          };</div><div>  }</div><div><br></div><div>  void ConstantConditionChecker::checkPostStmt(const IfStmt *ifStmt, CheckerContext &C) const</div>



<div>  {</div><div>      ASTContext& astContext = C.getASTContext();</div><div>      std::string sbuf;</div><div>      llvm::raw_string_ostream Out(sbuf);</div><div><br></div><div>      ifStmt->getCond()->printPretty(Out, NULL, PrintingPolicy(astContext.getLangOptions()));</div>



<div>      std::cerr << Out.str() << std::endl;</div><div>      std::cout << "Hello\n" << std::endl;</div><div>      std::cerr << "Hello cerr" << std::endl;</div><div>



      if (!BT)</div><div>          BT.reset(new BuiltinBug(Out.str().c_str()));</div><div>      BugReport* R = new BugReport(*BT, BT->getDescription(), C.getPredecessor());</div><div>      R->addRange(ifStmt->getSourceRange());</div>



<div>      C.EmitReport(R);</div><div><br></div><div>  }</div><div><br></div><div>  void ento::registerConstantConditionChecker(CheckerManager &mgr) {</div><div>      mgr.registerChecker<ConstantConditionChecker>();</div>



<div>  }</div></div><div><br></div></div></div>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>

</blockquote></div><br></div></div></div></blockquote></div><br></div>