[all-commits] [llvm/llvm-project] 985a72: [clang][Diagnostics] Provide source range to integ...

Takuya Shimizu via All-commits all-commits at lists.llvm.org
Sat Aug 19 06:05:55 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 985a72b6b3e74f0d29780b2a97b5817473338ffe
      https://github.com/llvm/llvm-project/commit/985a72b6b3e74f0d29780b2a97b5817473338ffe
  Author: Takuya Shimizu <shimizu2486 at gmail.com>
  Date:   2023-08-19 (Sat, 19 Aug 2023)

  Changed paths:
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/AST/Interp/Interp.h
    M clang/test/Misc/constexpr-source-ranges.cpp

  Log Message:
  -----------
  [clang][Diagnostics] Provide source range to integer-overflow warnings

BEFORE:

```
overflow.cpp:1:21: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
    1 | int x = __INT_MAX__ + 1 + 3;
      |                     ^
overflow.cpp:2:9: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
    2 | int a = -(1 << 31) + 1;
      |         ^
```
AFTER:

```
overflow.cpp:1:21: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
    1 | int x = __INT_MAX__ + 1 + 3;
      |         ~~~~~~~~~~~~^~~
overflow.cpp:2:9: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
    2 | int a = -(1 << 31) + 1;
      |         ^~~~~~~~~~
```

Reviewed By: tbaeder
Differential Revision: https://reviews.llvm.org/D157383




More information about the All-commits mailing list