[llvm-branch-commits] [cfe-branch] r278989 - Merging r278786:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 17 14:58:11 PDT 2016


Author: hans
Date: Wed Aug 17 16:58:11 2016
New Revision: 278989

URL: http://llvm.org/viewvc/llvm-project?rev=278989&view=rev
Log:
Merging r278786:
------------------------------------------------------------------------
r278786 | jamesm | 2016-08-16 02:45:36 -0700 (Tue, 16 Aug 2016) | 4 lines

Left shifts of negative values are defined if -fwrapv is set

This means we shouldn't emit ubsan detection code or warn.
Fixes PR25552.
------------------------------------------------------------------------

Added:
    cfe/branches/release_39/test/CodeGen/wrapv-lshr-sanitize.c
      - copied unchanged from r278786, cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
    cfe/branches/release_39/test/Sema/negative-shift-wrapv.c
      - copied unchanged from r278786, cfe/trunk/test/Sema/negative-shift-wrapv.c
Modified:
    cfe/branches/release_39/   (props changed)
    cfe/branches/release_39/lib/CodeGen/CGExprScalar.cpp
    cfe/branches/release_39/lib/Sema/SemaExpr.cpp

Propchange: cfe/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 17 16:58:11 2016
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763
+/cfe/trunk:275880,275967,276102,276350,276361,276473,276653,276716,276887,276891,276900,276979,276983,277095,277138,277141,277221,277307,277522,277743,277783,277796-277797,277852,277866,277889,277900,278139,278156,278234-278235,278393,278395,278763,278786
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_39/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CGExprScalar.cpp?rev=278989&r1=278988&r2=278989&view=diff
==============================================================================
--- cfe/branches/release_39/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/branches/release_39/lib/CodeGen/CGExprScalar.cpp Wed Aug 17 16:58:11 2016
@@ -2706,7 +2706,8 @@ Value *ScalarExprEmitter::EmitShl(const
     RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
 
   bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
-                      Ops.Ty->hasSignedIntegerRepresentation();
+                      Ops.Ty->hasSignedIntegerRepresentation() &&
+                      !CGF.getLangOpts().isSignedOverflowDefined();
   bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
   if (CGF.getLangOpts().OpenCL)

Modified: cfe/branches/release_39/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Sema/SemaExpr.cpp?rev=278989&r1=278988&r2=278989&view=diff
==============================================================================
--- cfe/branches/release_39/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/release_39/lib/Sema/SemaExpr.cpp Wed Aug 17 16:58:11 2016
@@ -8567,7 +8567,7 @@ static void DiagnoseBadShiftValues(Sema&
 
   // If LHS does not have a signed type and non-negative value
   // then, the behavior is undefined. Warn about it.
-  if (Left.isNegative()) {
+  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
     S.DiagRuntimeBehavior(Loc, LHS.get(),
                           S.PDiag(diag::warn_shift_lhs_negative)
                             << LHS.get()->getSourceRange());




More information about the llvm-branch-commits mailing list