[cfe-dev] Weak function pointers (was "SymbolRef and SVal confusion")
Richard
tarka.t.otter at googlemail.com
Sun Jan 27 13:40:11 PST 2013
On 25 Jan 2013, at 18:51, Jordan Rose <jordan_rose at apple.com> wrote:
> I see what you mean about duplicated checks. Here's an idea: put all the checks in evalCastFromLoc under a special case for casting to bool. Then in evalBinOpLL:
>
> if (rInt->isZeroConstant()) {
> if (op == BO_Sub)
> return evalCastFromLoc(lhs, resultTy);
> if (BinaryOperator::isComparisonOp(op))
> return evalBinOpNN(state, op,
> evalCastFromLoc(lhs, getContext().BoolTy),
> makeTruthVal(false, getContext().BoolTy));
> }
>
> That way you only have the ugly comparison once, and it's in SValBuilder rather than ConstraintManager.
This is a nice idea, but I don't think it will work. The problem is that evalCastFromLoc will then expect different return values for the same inputs depending on whether it is being called from evalBinOpLL or evalCast. I gave it a quick go, but it caused many tests to fail for varying reasons.
How about the attached diff instead? The function could be named more helpfully, but it does succeed at putting the ugly code in a single place, while changing the architecture as little as possible.
Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130127/5dcc024e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: weak3.diff
Type: application/octet-stream
Size: 8572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130127/5dcc024e/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130127/5dcc024e/attachment-0001.html>
More information about the cfe-dev
mailing list