From: Ted Kremenek Date: Mon, 20 Jul 2009 21:43:20 +0000 (+0000) Subject: Enhance GRExprEngine::EvalBind to handle some implicit casts from nonlocs to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc59aa57c525dc84eb5e5dd7ac76cac63630db46;p=clang Enhance GRExprEngine::EvalBind to handle some implicit casts from nonlocs to locs and vis versa. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76483 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 7459b806e2..006c3a7d9a 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1049,7 +1049,24 @@ void GRExprEngine::EvalBind(NodeSet& Dst, Expr* Ex, NodeTy* Pred, else { // We are binding to a value other than 'unknown'. Perform the binding // using the StoreManager. - newState = state->bindLoc(cast(location), Val); + Loc L = cast(location); + + // Handle implicit casts not reflected in the AST. This can be due to + // custom checker logic such as what handles OSAtomicCompareAndSwap. + if (!Val.isUnknownOrUndef()) + if (const TypedRegion *R = + dyn_cast_or_null(L.getAsRegion())) { + assert(R->isBoundable()); + QualType ValTy = R->getValueType(getContext()); + if (Loc::IsLocType(ValTy)) { + if (!isa(Val)) + Val = SVator.EvalCastNL(cast(Val), ValTy); + } + else if (!isa(Val)) + Val = SVator.EvalCastL(cast(Val), ValTy); + } + + newState = state->bindLoc(L, Val); } // The next thing to do is check if the GRTransferFuncs object wants to