]> granicus.if.org Git - clang/commit
-fcatch-undefined-behavior: add the -ftrapv checks to the set of things caught
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 25 Aug 2012 00:32:28 +0000 (00:32 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 25 Aug 2012 00:32:28 +0000 (00:32 +0000)
commit9d3e226acad5e23e562cde0a69362bb266f2a333
tree451bae1fb4f180c70d7c4e13fb30b50eeead561a
parentdf5faf5e7ae6823d0af0b801c4ac26d47f2cee97
-fcatch-undefined-behavior: add the -ftrapv checks to the set of things caught
by this mode, and also check for signed left shift overflow. The rules for the
latter are a little subtle:

 * neither C89 nor C++98 specify the behavior of a signed left shift at all
 * in C99 and C11, shifting a 1 bit into the sign bit has undefined behavior
 * in C++11, with core issue 1457, shifting a 1 bit *out* of the sign bit has
   undefined behavior

As of this change, we use the C99 rules for all C language variants, and the
C++11 rules for all C++ language variants. Once we have individual
-fcatch-undefined-behavior= flags, this should be revisited.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162634 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprScalar.cpp
test/CodeGen/catch-undef-behavior.c
test/CodeGen/integer-overflow.c
test/CodeGen/trapv.c
test/CodeGenCXX/catch-undef-behavior.cpp