Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -10201,18 +10201,22 @@ SmallVector Exprs(1, E); do { - Expr *E = Exprs.pop_back_val(); + Expr *OriginalE = Exprs.pop_back_val(); + Expr *E = OriginalE->IgnoreParenCasts(); - if (isa(E->IgnoreParenCasts())) { - E->IgnoreParenCasts()->EvaluateForOverflow(Context); + if (isa(E)) { + E->EvaluateForOverflow(Context); continue; } - if (auto InitList = dyn_cast(E)) + if (auto InitList = dyn_cast(OriginalE)) Exprs.append(InitList->inits().begin(), InitList->inits().end()); - - if (isa(E)) - E->IgnoreParenCasts()->EvaluateForOverflow(Context); + else if (isa(OriginalE)) + E->EvaluateForOverflow(Context); + else if (auto Call = dyn_cast(E)) + Exprs.append(Call->arg_begin(), Call->arg_end()); + else if (auto Message = dyn_cast(E)) + Exprs.append(Message->arg_begin(), Message->arg_end()); } while (!Exprs.empty()); } Index: clang/test/Sema/integer-overflow.c =================================================================== --- clang/test/Sema/integer-overflow.c +++ clang/test/Sema/integer-overflow.c @@ -158,6 +158,18 @@ return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))); } +void check_integer_overflows_in_function_calls() { +// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} + (void)f0(4608 * 1024 * 1024); + +// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} + uint64_t x = f0(4608 * 1024 * 1024); + +// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}} + uint64_t (*f0_ptr)(uint64_t) = &f0; + (void)(*f0_ptr)(4608 * 1024 * 1024); +} + struct s { unsigned x; unsigned y; Index: clang/test/SemaCXX/integer-overflow.cpp =================================================================== --- clang/test/SemaCXX/integer-overflow.cpp +++ clang/test/SemaCXX/integer-overflow.cpp @@ -169,3 +169,15 @@ // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))); } + +void check_integer_overflows_in_function_calls() { +// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} + (void)f0(4608 * 1024 * 1024); + +// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} + uint64_t x = f0(4608 * 1024 * 1024); + +// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}} + uint64_t (*f0_ptr)(uint64_t) = &f0; + (void)(*f0_ptr)(4608 * 1024 * 1024); +} Index: clang/test/SemaObjC/integer-overflow.m =================================================================== --- /dev/null +++ clang/test/SemaObjC/integer-overflow.m @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -Wno-objc-root-class -fsyntax-only -verify %s + +@interface Foo +@end + +@implementation Foo +- (int)add:(int)a with:(int)b { + return a + b; +} + +- (void)testIntegerOverflows { +// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} + (void)[self add:0 with:4608 * 1024 * 1024]; +} +@end