r178318 - Add static analyzer support for conditionally executing static initializers.

Jordan Rose jordan_rose at apple.com
Thu Mar 28 17:57:29 PDT 2013


On Mar 28, 2013, at 17:09 , Ted Kremenek <kremenek at apple.com> wrote:

> +void ExprEngine::processStaticInitializer(const DeclStmt *DS,
> +                                          NodeBuilderContext &BuilderCtx,
> +                                          ExplodedNode *Pred,
> +                                          clang::ento::ExplodedNodeSet &Dst,
> +                                          const CFGBlock *DstT,
> +                                          const CFGBlock *DstF) {
> +  currBldrCtx = &BuilderCtx;
> +
> +  const VarDecl *VD = cast<VarDecl>(DS->getSingleDecl());
> +  ProgramStateRef state = Pred->getState();
> +  bool initHasRun = state->contains<InitializedGlobalsSet>(VD);
> +  BranchNodeBuilder builder(Pred, Dst, BuilderCtx, DstT, DstF);
> +
> +  if (!initHasRun) {
> +    state = state->add<InitializedGlobalsSet>(VD);
> +  }
> +
> +  builder.generateNode(state, initHasRun, Pred);
> +  builder.markInfeasible(!initHasRun);
> +
> +  currBldrCtx = 0;
> +}


Hm, this isn't really correct, since most calls to functions will happen after the first. But it's consistent with what we're doing now. I guess it's something we can revisit later.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130328/80bcb44f/attachment.html>


More information about the cfe-commits mailing list