[cfe-dev] basic analyzer checker programstate problem

Richard tarka.t.otter at googlemail.com
Thu Dec 13 08:11:54 PST 2012


hi

another fairly basic question that i am having trouble with: i am trying to set some state in an analyzer checker in checkBranchCondition and then retrieve it in checkPreCall. the state is being set ok, but for some reason is never readable in successive checkPreCall callbacks, the state map always returns NULL. i thought that the ProgramState data map was supposed to propagate down the graph, is this not how it works? i can see the node that is added to the graph, so why can i not get the state that is set?

here is the code i am using, i followed some of the other checkers pretty closely, am i doing something stupid here?

void UnavailableMethodChecker::checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const
{
    VersionTuple V = getAvailabilityForStmt(Condition, Ctx);
    ProgramStateRef State = Ctx.getState();
    SymbolRef Sym = State->getSVal(Condition, Ctx.getLocationContext()).getAsSymbol();
    State = State->set<AvailabilityMap>(Sym, AvailabilityState(V));
    Ctx.addTransition(State);
}

void UnavailableMethodChecker::checkPreCall(const CallEvent &Call, CheckerContext &Ctx) const
{
    ...

    ProgramStateRef State = Ctx.getState();
    AvailabilityMapTy M = State->get<AvailabilityMap>();
    // M is always NULL here

    for (AvailabilityMapTy::iterator I = M.begin(), E = M.end(); I != E; ++I) {
        AvailabilityState A = I->second;
        if (A.Version >= CallVersion) {
            return;
        }
    }

    ...
}

thanks for the help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121213/0b0a3270/attachment.html>


More information about the cfe-dev mailing list