[clang] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)
Justin Stitt via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 27 15:10:19 PDT 2025
================
@@ -1480,6 +1480,14 @@ class DeclRefExpr final
return DeclRefExprBits.IsImmediateEscalating;
}
+ bool isOverflowBehaviorDiscarded() const {
----------------
JustinStitt wrote:
The purpose is to emit a different diagnostic for when an OBT is lost during assignment.
```c
int __no_wrap a = 1;
int b = a + 13;
warning: implicit conversion from '__no_wrap int' to 'int' during assignment discards overflow behavior [-Wimplicit-overflow-behavior-conversion-assignment]
11 | int b = a + 13;
| ~ ~~^~~~
```
I've reworked this slightly in [8c875bb](https://github.com/llvm/llvm-project/pull/148914/commits/8c875bb1750c1f5fb1ac37ead58fb046501dd9f2). I moved the flag from `DeclRefExprBits` to `ExprBits` and added a comment. I also simplified the logic in `CheckOverflowBehaviorTypeConversion`.
https://github.com/llvm/llvm-project/pull/148914
More information about the cfe-commits
mailing list