Clang checker: 'beginning of function' hook?

Gábor,

Thanks for the helpful suggestions. Your suspicion that checkPreCall is not invoked for the entry function was correct. My current solution looks like this:

void Checker::checkPostStmt(const Expr* S, CheckerContext &C) const {
if (const DeclRefExpr* expr = dyn_cast(S->IgnoreImplicit())) {
if (const ParmVarDecl* param = dyn_cast(expr->getDecl())) {
const SymbolRef sym = C.getSVal(S).getAsSymbol();
if (!sym) return;
ProgramStateRef State = C.getState();
const MyState* arg_state = State->get(sym);
if (arg_state) return; // Only interested in first encounter

}
}
}

For some reason it did not work to register for PostStmt. I believe the checker does not descend into ImplicitCast expressions… so I did that part manually. A bit of a hack, but it gets the job done, and it has the lazy-initialized quality that you mentioned.

On a somewhat related note, I noticed that unused function parameters are never reaped by the DeadSymbols callback. I’m considering doing my own special handling for these, as I need to know when a parameter is ‘leaked’ for my purposes. Any ideas there?

Best and thanks again,
Aemon