[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-11-10 Thread Justin Stitt via lldb-commits
JustinStitt wrote: It is my understanding that we cannot have both 1) overloading on OBT and 2) no mangling on OBT. FWIW, our first user of this may very well be the Linux kernel and I don't think they care much about the overloading semantics of OBTs. Personally, I also don't care which way w

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-11-05 Thread Justin Stitt via lldb-commits
JustinStitt wrote: > Just to be clear, that's going to impact things like function overloading > (which we support in C as well as C++), type inspection via `_Generic`, > template type deduction in C++, etc. That's not an argument for or against > anything, just a reminder that making these tr

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-11-05 Thread Justin Stitt via lldb-commits
JustinStitt wrote: Pinging @kees as he might have concerns with the first 80% of your comment but for me this part was interesting: @rjmccall > There was a secondary discussion about whether OBTs should be part of the > signature of the function for the purposes of overloading, mangling, and s

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-11-04 Thread Justin Stitt via lldb-commits
JustinStitt wrote: Summarizing the round table w/ @ojhunt @rjmccall @mizvekov @efriedma-quic (and others) it seems the current design ([summarized by John in the rfc](https://discourse.llvm.org/t/rfc-v2-clang-introduce-overflowbehaviortypes-for-wrapping-and-non-wrapping-arithmetic/86507/46?u=ju

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-28 Thread Justin Stitt via lldb-commits
JustinStitt wrote: @ojhunt I'll get a roundtable slot for tomorrow. Would you be interested in attending? I'll grab a 10:30-11:00am slot for 10/28. Maybe we can page in @kees digitally. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commit

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, << "' " << Values << ")"; return DecoratedString; } + +TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S); JustinStitt wrote: OK, I'll add

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
@@ -409,6 +426,7 @@ class DeclSpec { SourceRange TypeofParensRange; SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc, TQ_unalignedLoc; + SourceLocation OB_wrapLoc, OB_no_wrapLoc; JustinStitt wrote: Right, I'll make the change

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
JustinStitt wrote: > Would it be reasonable to split this into two phases? I think two phases is a good idea. This lets us get OBTs sooner and design __strict separately. Does anyone know WG14s consensus over strong typedefs? __strict is similar enough that I'm curious to know what folks thou

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, << "' " << Values << ")"; return DecoratedString; } + +TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S); JustinStitt wrote: @ojhunt Can

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
JustinStitt wrote: @rjmccall > You linked me to this post promising a detailed discussion of the model, but > I can't quite piece out what overflow model you're actually proposing for the > compliant mode. :) Sorry, I tried to fit all the information in my post without writing a book. To sum

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
JustinStitt wrote: > Right, I think `c` is what is already happening with `b`: a cast to `u16` > tells us nothing about the desired OB. We need to say `u16 __ob_trap` ("I > want to trap") or `u16 __ob_wrap` ("I want wrap-around on overflow"). OK, that sounds fine to me. It addresses the issue

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
@@ -9744,6 +9744,16 @@ static void DiagnoseNarrowingInInitList(Sema &S, case NK_Constant_Narrowing: { // A constant value was narrowed. + +// Overflow behavior destination types with a 'wrap' kind can elide JustinStitt wrote: Without the OBT check i

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-18 Thread Justin Stitt via lldb-commits
@@ -9744,6 +9744,16 @@ static void DiagnoseNarrowingInInitList(Sema &S, case NK_Constant_Narrowing: { // A constant value was narrowed. + +// Overflow behavior destination types with a 'wrap' kind can elide JustinStitt wrote: Check out `OverflowBeha

[Lldb-commits] [lldb] [lldb/cmake] unittests: Breakpoint: remove liblldb dep (PR #162571)

2025-10-17 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt created https://github.com/llvm/llvm-project/pull/162571 Remove the `liblldb` link target for these tests to fix CI failures. Commit 02572c6e9bbb ("[lldb] Enforce that only the LLDB API unit tests can link liblldb") disallows linking against liblldb for most test

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Justin Stitt via lldb-commits
JustinStitt wrote: I think there is some confusion in this thread about how to tell the compiler about intentional data loss. The UX I like the most is something like the following: ```c void foo() { int __ob_trap a = -1; u16 b = a; // trap, semantics we just agreed upon. implicit casts ar

[Lldb-commits] [lldb] [lldb/cmake] unittests: Breakpoint: remove liblldb dep (PR #162571)

2025-10-17 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/162571 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Justin Stitt via lldb-commits
@@ -2427,9 +2438,16 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, // Complex promotion (Clang extension) SCS.Second = ICK_Complex_Promotion; FromType = ToType.getUnqualifiedType(); + } else if (S.IsOverflowBehaviorTypePromotion(FromType

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Justin Stitt via lldb-commits
JustinStitt wrote: FYI, I'm meeting with @kees off-thread today to analyze kernel use cases and digest @ojhunt's review comments. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-17 Thread Justin Stitt via lldb-commits
JustinStitt wrote: With all the review it is clear that we have to choose some new semantics for OBTs. It is also important that OBTs are useful in their design and purpose for many projects. OBTs should provide type-level overflow behavior handling. With this goal in mind, there's two custome

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-14 Thread Justin Stitt via lldb-commits
JustinStitt wrote: @kees > If we don't follow what I'm describing, this becomes meaningless: > > ``` > int __ob_trap big = runtime_1024; > ... > char __ob_wrap byte = big; // is this supposed to wrap or trap? I say wrap -- > we're describing how "byte" behaves > ``` > > How can we perform an

[Lldb-commits] [lldb] [lldb/cmake] unittests: Breakpoint: remove liblldb dep (PR #162571)

2025-10-13 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt closed https://github.com/llvm/llvm-project/pull/162571 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [lldb] [lldb/cmake] unittests: Breakpoint: remove liblldb dep (PR #162571)

2025-10-12 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/162571 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-10-02 Thread Justin Stitt via lldb-commits
JustinStitt wrote: OK, I'll work on scaling back my custom promotion/conversion rules. Might take a couple days because every test needs to be rewritten too. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list lldb-commits@l

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-29 Thread Justin Stitt via lldb-commits
JustinStitt wrote: > Either always returning false (wrapping to uint8_t), or trapping in the > overflow (?) check due to early narrowing, or returning false incorrectly but > only if obt is enabled, and if obt is not enabled the only overflow exists on > the promoted, but that can be prevented

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-25 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-25 Thread Justin Stitt via lldb-commits
@@ -359,6 +366,16 @@ class DeclSpec { LLVM_PREFERRED_TYPE(TQ) unsigned TypeQualifiers : 5; // Bitwise OR of TQ. + // overflow behavior qualifiers + LLVM_PREFERRED_TYPE(bool) JustinStitt wrote: Sounds good to me. I'll make the change. https://github.co

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-25 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
@@ -4043,6 +4043,33 @@ def note_cannot_use_trivial_abi_reason : Note< "it has a __weak field|it has a field of a non-trivial class type|" "it has an address-discriminated '__ptrauth' field}1">; +// OverflowBehavior attribute +def err_overflow_behavior_unknown_ident +:

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
@@ -9744,6 +9744,16 @@ static void DiagnoseNarrowingInInitList(Sema &S, case NK_Constant_Narrowing: { // A constant value was narrowed. + +// Overflow behavior destination types with a 'wrap' kind can elide JustinStitt wrote: > Why is that a reasona

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
@@ -2845,6 +2866,41 @@ bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) { ToComplex->getElementType()); } +bool Sema::IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType) { JustinStitt wrote: Yes the i

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
@@ -4043,6 +4043,33 @@ def note_cannot_use_trivial_abi_reason : Note< "it has a __weak field|it has a field of a non-trivial class type|" "it has an address-discriminated '__ptrauth' field}1">; +// OverflowBehavior attribute +def err_overflow_behavior_unknown_ident +:

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-24 Thread Justin Stitt via lldb-commits
@@ -1146,23 +1161,16 @@ def Parentheses : DiagGroup<"parentheses", // - conversion warnings for literals are on by default // - bool-to-pointer conversion warnings are on by default // - __null-to-integer conversion warnings are on by default -def Conversion : DiagGroup<"

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-20 Thread Justin Stitt via lldb-commits
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -foverflow-behavior-types -std=c++11 -ast-print %s -o - | FileCheck %s + +extern int __attribute__((overflow_behavior(no_wrap))) a; +extern int __attribute__((overflow_behavior(wrap))) b; + +// CHECK: extern __no_wrap int a; +// CHECK: extern _

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-19 Thread Justin Stitt via lldb-commits
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, << "' " << Values << ")"; return DecoratedString; } + +TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S); JustinStitt wrote: > If you fee

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-19 Thread Justin Stitt via lldb-commits
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty, << "' " << Values << ")"; return DecoratedString; } + +TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S); JustinStitt wrote: OK, so shoul

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-18 Thread Justin Stitt via lldb-commits
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -foverflow-behavior-types -std=c++11 -ast-print %s -o - | FileCheck %s + +extern int __attribute__((overflow_behavior(no_wrap))) a; +extern int __attribute__((overflow_behavior(wrap))) b; + +// CHECK: extern __no_wrap int a; +// CHECK: extern _

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
@@ -2165,6 +2167,26 @@ void TypePrinter::printBTFTagAttributedAfter(const BTFTagAttributedType *T, printAfter(T->getWrappedType(), OS); } +void TypePrinter::printOverflowBehaviorBefore(const OverflowBehaviorType *T, + raw_ostream

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
@@ -7477,6 +7477,10 @@ void TypeLocReader::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) { // Nothing to do. } +void TypeLocReader::VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) { + // Nothing to do. +} JustinStitt wrote: Right. Done

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
@@ -112,6 +112,25 @@ class LangOptionsBase { SOB_Trapping }; + // Used by __attribute__((overflow_behavior())) to describe overflow behavior + // on a per-type basis. + enum OverflowBehaviorKind { +// Default C standard behavior (type dependent). +OB_Unset, +

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
https://github.com/JustinStitt edited https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-17 Thread Justin Stitt via lldb-commits
@@ -112,6 +112,25 @@ class LangOptionsBase { SOB_Trapping }; + // Used by __attribute__((overflow_behavior())) to describe overflow behavior + // on a per-type basis. + enum OverflowBehaviorKind { +// Default C standard behavior (type dependent). +OB_Unset, +

[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

2025-09-16 Thread Justin Stitt via lldb-commits
JustinStitt wrote: ping. rebased and fixed tests after `Commit b24769855d97: [Clang] [Sema] Make -Wincompatible-pointer-types an error by default (#157364)` caused some tests to fail. https://github.com/llvm/llvm-project/pull/148914 ___ lldb-commits