[cfe-dev] Why isn't PostStmt<DeclStmt> invoked? with code to reproduce.

Aemon Cannon aemoncannon at gmail.com
Thu Sep 12 05:31:47 PDT 2013


I'm trying to understand why this checker behaves as it does. I have a
project where I would like to register for PostStmt<DeclStmt>, but, in
spite of the fact that this is one of the callbacks mentioned explicitly in
CheckerDocumentation.cpp, it doesn't ever get invoked.

I just synced my LLVM and Clang trees last night.

Thanks much!


-----

  class TracingChecker : public Checker<check::PreStmt<DeclStmt>,

check::PostStmt<DeclStmt> > {
   public:

    void checkPreStmt(const DeclStmt *s, CheckerContext &C) const {
      llvm::outs() << "checkPreStmt<DeclStmt> ";
      s->dump();
      llvm::outs() << "\n\n";
    }

    void checkPostStmt(const DeclStmt *s, CheckerContext &C) const {
      llvm::outs() << "checkPreStmt<DeclStmt> ";
      s->dump();
      llvm::outs() << "\n";
    }

  };



----- input program ------

struct Thing {
  int legs;
};

bool test() {
  int i;
  int j = 1;
  Thing thing;
  return true;
}



-------- analyzer arguments --

~/projects/llvm/Release+Asserts/bin/clang -cc1 -analyze
-analyzer-checker=debug.Trace reproduce.cc



------- output ----------

checkPreStmt<DeclStmt> DeclStmt 0x7fb8b402c1d8
`-VarDecl 0x7fb8b402c180 i 'int'


checkPreStmt<DeclStmt> DeclStmt 0x7fb8b4073e88
`-VarDecl 0x7fb8b4073e10 j 'int'
  `-IntegerLiteral 0x7fb8b4073e68 'int' 1


checkPreStmt<DeclStmt> DeclStmt 0x7fb8b4074278
`-VarDecl 0x7fb8b4073eb0 thing 'struct Thing'
  `-CXXConstructExpr 0x7fb8b4074248 'struct Thing' 'void (void)'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130912/0ae60d04/attachment.html>


More information about the cfe-dev mailing list