Left shifts of negative values are defined if -fwrapv is set
This means we shouldn't emit ubsan detection code or warn.
Fixes PR25552.
llvm-svn: 278786
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 78fa995..41c8a4c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8670,7 +8670,7 @@
// 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());