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
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
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
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
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
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType
Ty,
<< "' " << Values << ")";
return DecoratedString;
}
+
+TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S);
JustinStitt wrote:
OK, I'll add
@@ -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
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
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType
Ty,
<< "' " << Values << ")";
return DecoratedString;
}
+
+TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S);
JustinStitt wrote:
@ojhunt Can
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
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
@@ -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
@@ -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
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
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
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
@@ -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
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
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.
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
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
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
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
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
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
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
@@ -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
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
@@ -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
+:
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
@@ -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
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
@@ -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
@@ -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
+:
@@ -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<"
@@ -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 _
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType
Ty,
<< "' " << Values << ")";
return DecoratedString;
}
+
+TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S);
JustinStitt wrote:
> If you fee
@@ -339,6 +389,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType
Ty,
<< "' " << Values << ")";
return DecoratedString;
}
+
+TryConvertOverflowBehaviorTypeToDiagnosticString(Context, Ty, S);
JustinStitt wrote:
OK, so shoul
@@ -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 _
@@ -2165,6 +2167,26 @@ void TypePrinter::printBTFTagAttributedAfter(const
BTFTagAttributedType *T,
printAfter(T->getWrappedType(), OS);
}
+void TypePrinter::printOverflowBehaviorBefore(const OverflowBehaviorType *T,
+ raw_ostream
@@ -7477,6 +7477,10 @@ void
TypeLocReader::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
// Nothing to do.
}
+void TypeLocReader::VisitOverflowBehaviorTypeLoc(OverflowBehaviorTypeLoc TL) {
+ // Nothing to do.
+}
JustinStitt wrote:
Right. Done
@@ -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,
+
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
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
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
@@ -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,
+
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
47 matches
Mail list logo