diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-03-15 17:03:56 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-03-15 17:03:56 +0000 |
commit | a30bab4b5d421fb148a732da31621cffe51519ee (patch) | |
tree | dc65fcee34f14d37a4ecde1128d5750036d58832 /lib/Sema/SemaChecking.cpp | |
parent | 2cd889d6d97db0cf73930873871aa4a542e84b89 (diff) |
c: Also chek for integer overflow for '%' operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 3926f01ea6..2f8d8576b9 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -5188,8 +5188,16 @@ void Sema::CheckImplicitConversions(Expr *E, SourceLocation CC) { void Sema::CheckForIntOverflow (Expr *E) { if (const BinaryOperator *BExpr = dyn_cast<BinaryOperator>(E->IgnoreParens())) { unsigned Opc = BExpr->getOpcode(); - if (Opc != BO_Add && Opc != BO_Sub && Opc != BO_Mul && Opc != BO_Div) - return; + switch (Opc) { + case BO_Add: + case BO_Sub: + case BO_Mul: + case BO_Div: + case BO_Rem: + break; + default: + return; + } llvm::SmallVector<PartialDiagnosticAt, 4> Diags; E->EvaluateForOverflow(Context, &Diags); } |