r177137 - [analyzer] Teach trackNullOrUndef to look through	ternary operators
    Jordan Rose 
    jordan_rose at apple.com
       
    Fri Mar 15 09:03:13 PDT 2013
    
    
  
On Mar 14, 2013, at 18:15 , Anna Zaks <ganna at apple.com> wrote:
> +  // Peel off the ternary operator.
> +  if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(S)) {
> +    ProgramStateRef State = N->getState();
> +    SVal CondVal = State->getSVal(CO->getCond(), N->getLocationContext());
> +    if (State->isNull(CondVal).isConstrainedTrue()) {
> +      S = CO->getTrueExpr();
> +    } else {
> +      assert(State->isNull(CondVal).isConstrainedFalse());
> +      S =  CO->getFalseExpr();
> +    }
> +  }
I'm not sure this is good enough; we don't know that the CO->getCond() is still live if the ternary operator is, say, inside of a cast (which would make the assertion fire). The "right" way to do this is to back up along the graph until we (a) get to the ternary operator node, or (b) get to the block edge that tells us which path was chosen.
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130315/7c0c88fb/attachment.html>
    
    
More information about the cfe-commits
mailing list