[cfe-commits] r68221 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/Driver/Options.def lib/CodeGen/CGExprScalar.cpp tools/clang-cc/clang-cc.cpp

Eli Friedman eli.friedman at gmail.com
Wed Apr 1 11:28:00 PDT 2009


On Wed, Apr 1, 2009 at 11:19 AM, Mike Stump <mrs at apple.com> wrote:
> Author: mrs
> Date: Wed Apr  1 13:19:33 2009
> New Revision: 68221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=68221&view=rev
> Log:
> Add -ftrapv support, patch from David Chisnall; well all except the
> clang option code that is.

Hmm... this doesn't appear to be compatible with the gcc
implementation of -ftrapv, so it might not be a good idea to give the
option the same name.

> +    assert(Ops.Ty->isUnsignedIntegerType() &&
> +        "Must be either a signed or unsigned integer op");
> +    switch (Ops.E->getOpcode()) {
> +      case BinaryOperator::Add:
> +        OpID = 1;
> +        IID = llvm::Intrinsic::uadd_with_overflow;
> +        break;
> +      case BinaryOperator::Sub:
> +        OpID = 2;
> +        IID = llvm::Intrinsic::usub_with_overflow;
> +        break;
> +      case BinaryOperator::Mul:
> +        OpID = 3;
> +        IID = llvm::Intrinsic::umul_with_overflow;
> +        break;
> +      default:
> +        assert(false && "Unsupported operation for overflow detection");
> +    }

Unsigned "overflow" is perfectly well-defined per C99; I don't think
we want to trap without the user explicitly asking for it.

-Eli




More information about the cfe-commits mailing list