[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-27 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/154618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-27 Thread Dan Liew via cfe-commits
delcypher wrote: @thurstond Thanks for the feedback. I've tried to address your comments and I also added a brief discussion of optimized-vs-unoptimized builds. https://github.com/llvm/llvm-project/pull/154618 ___ cfe-commits mailing list cfe-commits@

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-27 Thread Dan Liew via cfe-commits
@@ -166,7 +174,9 @@ Non-comprehensive list of changes in this release New Compiler Flags -- -- New option ``-fno-sanitize-annotate-debug-info-traps`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanit

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-27 Thread Dan Liew via cfe-commits
delcypher wrote: @vitalybuka Thanks for approving. I think I addressed everyone's comments so I'm going to rebase, check everything still works, and then land. https://github.com/llvm/llvm-project/pull/154618 ___ cfe-commits mailing list cfe-commits@l

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
@@ -1,9 +1,32 @@ // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \ -// RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -emit-llvm %s -o - | FileCheck %s +// RUN: -fsanitize=signed-integer-overf

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/154618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/154618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
delcypher wrote: @thurstond I implemented a `-fsanitize-debug-trap-reasons=` flag takes an enum value. It takes either `none`, `basic` (what we had before this patch), or `detailed` (the new behavior added by this patch). For compatibility I kept the binary forms of the flags around and made t

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
delcypher wrote: @thurstond > I agree it can be useful in many cases, but it could also make the debug info > unbearably large. (Anecdata: Big Google disables the current trap-reasons > annotations in their internal toolchain, because it made the debug info up to > 15% larger, even without t

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
@@ -1534,6 +1536,103 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) { return Report(SourceLocation(), DiagID); } +//===--===// +// RuntimeTrapDiagnosticBuilder and helper classes +//

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/22] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/20] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/19] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/21] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/18] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-26 Thread Dan Liew via cfe-commits
@@ -1839,19 +1842,43 @@ void ScalarExprEmitter::EmitBinOpCheck( StaticData.push_back(CGF.EmitCheckTypeDescriptor(Info.Ty)); } else { // Arithmetic overflow (+, -, *). + int ArithOverflowKind = 0; switch (Opcode) { - case BO_Add: Check = Sanitize

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/14] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/13] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/12] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/11] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
@@ -1534,6 +1536,103 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) { return Report(SourceLocation(), DiagID); } +//===--===// +// RuntimeTrapDiagnosticBuilder and helper classes +//

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
@@ -0,0 +1,21 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apac

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154618 >From db45694078e74e2c080e40dd8ba635d2c9f313c6 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Aug 2025 15:08:44 -0700 Subject: [PATCH 01/10] [UBSan][BoundsSafety] Implement support for more expressive

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
@@ -1534,6 +1536,103 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) { return Report(SourceLocation(), DiagID); } +//===--===// +// RuntimeTrapDiagnosticBuilder and helper classes +//

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
@@ -1534,6 +1536,103 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) { return Report(SourceLocation(), DiagID); } +//===--===// +// RuntimeTrapDiagnosticBuilder and helper classes +//

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-25 Thread Dan Liew via cfe-commits
@@ -1534,6 +1536,103 @@ inline DiagnosticBuilder DiagnosticsEngine::Report(unsigned DiagID) { return Report(SourceLocation(), DiagID); } +//===--===// +// RuntimeTrapDiagnosticBuilder and helper classes +//

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-22 Thread Dan Liew via cfe-commits
delcypher wrote: @Sirraide @ilovepi I've changed the implementation to use a `TrapReason` object to store the trap message and category. This allows cleaning up the `TrapDiagnosticBuilder` API (maybe it should be called `TrapReasonBuilder` now?) so it's much more similar to the `DiagnosticBui

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-21 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/154618 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][Diagnostics] Prevent incorrect clang-format reformatting in some headers related to Clang diagnostics (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
delcypher wrote: @erichkeane @Sirraide I just reformatted the entire files (opting out the enum that declares the ` DIAG_START_*` constants for readability. Assuming CI passes, is this good to go? https://github.com/llvm/llvm-project/pull/154628 ___

[clang] [NFC][Diagnostics] Prevent incorrect clang-format reformatting in some headers related to Clang diagnostics (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/154628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][Diagnostics] Reformat `DiagnosticIDs.h` and `AllDiagnostics.h` (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/154628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][Diagnostics] Reformat `DiagnosticIDs.h` and `AllDiagnostics.h` (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
delcypher wrote: The CI failure is due to an unrelated test failure. ``` Unresolved Tests (1): lldb-api :: tools/lldb-dap/moduleSymbols/TestDAP_moduleSymbols.py ``` https://github.com/llvm/llvm-project/pull/154628 ___ cfe-

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-21 Thread Dan Liew via cfe-commits
@@ -30,6 +30,7 @@ def CLASS_REMARK: DiagClass; def CLASS_WARNING : DiagClass; def CLASS_EXTENSION : DiagClass; def CLASS_ERROR : DiagClass; +def CLASS_TRAP : DiagClass; delcypher wrote: My initial prototype didn't add a new class but after think

[clang] [lldb] [UBSan][BoundsSafety] Implement support for more expressive "trap reasons" (PR #154618)

2025-08-21 Thread Dan Liew via cfe-commits
@@ -30,4 +30,5 @@ #include "clang/Basic/DiagnosticAnalysisKinds.inc" #include "clang/Basic/DiagnosticRefactoringKinds.inc" #include "clang/Basic/DiagnosticInstallAPIKinds.inc" +#include "clang/Basic/DiagnosticCodeGenKinds.inc" delcypher wrote: So the reason I

[clang] [NFC][Diagnostics] Reformat `DiagnosticIDs.h` and `AllDiagnostics.h` (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/154628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][Diagnostics] Prevent incorrect clang-format reformatting in some headers related to Clang diagnostics (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154628 >From 7c8a131a77b4bad590710a2292aece222739ebf0 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 20 Aug 2025 14:47:26 -0700 Subject: [PATCH] [NFC][Diagnostics] Reformat `DiagnosticIDs.h` and `AllDiagnostics.

[clang] [NFC][Diagnostics] Prevent incorrect clang-format reformatting in some headers related to Clang diagnostics (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
https://github.com/delcypher updated https://github.com/llvm/llvm-project/pull/154628 >From 62eccfc3e0a50da8c2532b9560a742ca4da21366 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 20 Aug 2025 14:47:26 -0700 Subject: [PATCH] [NFC][Diagnostics] Reformat `DiagnosticIDs.h` and `AllDiagnostics.

[clang] [NFC][Diagnostics] Prevent incorrect clang-format reformatting in some headers related to Clang diagnostics (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
@@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_BASIC_ALLDIAGNOSTICS_H #define LLVM_CLANG_BASIC_ALLDIAGNOSTICS_H +// clang-format off delcypher wrote: @Sirraide Is it both files you were thinking of reformatting? I'm happy to reformat `AllDiagnostics.h` but `clang-form

[clang] [NFC][Diagnostics] Prevent incorrect clang-format reformatting in some headers related to Clang diagnostics (PR #154628)

2025-08-21 Thread Dan Liew via cfe-commits
@@ -14,6 +14,7 @@ #ifndef LLVM_CLANG_BASIC_ALLDIAGNOSTICS_H #define LLVM_CLANG_BASIC_ALLDIAGNOSTICS_H +// clang-format off delcypher wrote: I had assumed that the inclusion order was deliberate but taking a closer look I see it doesn't actually match the dec

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-26 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/145967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-24 Thread Dan Liew via cfe-commits
delcypher wrote: @anthonyhatran Oh and don't forget about https://github.com/llvm/llvm-project/pull/145967#discussion_r2229499715 as well. https://github.com/llvm/llvm-project/pull/145967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-24 Thread Dan Liew via cfe-commits
https://github.com/delcypher approved this pull request. LGTM. Let's wait for @thurstond to respond regarding the flag name. https://github.com/llvm/llvm-project/pull/145967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-24 Thread Dan Liew via cfe-commits
@@ -2595,6 +2595,16 @@ def fsanitize_undefined_trap_on_error def fno_sanitize_undefined_trap_on_error : Flag<["-"], "fno-sanitize-undefined-trap-on-error">, Group, Alias, AliasArgs<["undefined"]>; +defm sanitize_annotate_debug_info_traps +: BoolFOption< +

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Dan Liew via cfe-commits
delcypher wrote: > What is debug info size impact? We'll ask @anthonyhatran to run some experiments on a few open source projects (if you have any that you interested in then particular please let us know). I wonder how much this will matter in practice though because (at least for Apple plat

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Dan Liew via cfe-commits
@@ -85,6 +85,96 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetUBSanTrapForHandler(SanitizerHandler ID) { + switch

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Dan Liew via cfe-commits
@@ -85,6 +85,96 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetUBSanTrapForHandler(SanitizerHandler ID) { -

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Dan Liew via cfe-commits
delcypher wrote: @PiJoules > Moving forward, I think it would be good to gather consensus on a better > scheme with respect to verbose messages handled by the debugger. Rather than > baking a custom format into the function name, we think it's more portable > and straightforward to use stand

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Dan Liew via cfe-commits
delcypher wrote: @fmayer > I would prefer this to be behind a flag (not necessarily in this PR), even if > it's default turned on. People might not want synthetic frames added to their > debug information and the top frame to point to the real code; also as this > somewhat overlaps with the l

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
@@ -730,6 +754,18 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, options::OPT_fno_sanitize_recover_EQ); RecoverableKinds &= Kinds; + // Parse any -fsanitize-trap=<...> flags the user provided, then + // diagnose any which do not have a matching -fsanitize=<...>

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. Looks good for the sketch patch. I have a few minor questions and nits that I've left. Please add a few driver test cases to illustrate how you expect this to work (including a test case that suppresses the warning). https://

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/147997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
@@ -348,6 +348,30 @@ parseSanitizeSkipHotCutoffArgs(const Driver &D, const llvm::opt::ArgList &Args, return Cutoffs; } +// Given a set of mismatched bits, TrapOnly (bits the user asked to trap but +// that aren’t actually enabled), emit a warning based on -fsanitize-trap=NA

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
@@ -730,6 +754,18 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, options::OPT_fno_sanitize_recover_EQ); RecoverableKinds &= Kinds; + // Parse any -fsanitize-trap=<...> flags the user provided, then + // diagnose any which do not have a matching -fsanitize=<...>

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
@@ -874,4 +874,9 @@ def warn_drv_openacc_without_cir : Warning<"OpenACC directives will result in no runtime behavior; use " "-fclangir to enable runtime effect">, InGroup; + +def warn_drv_sanitize_trap_mismatch : Warning< + "-fsanitize-trap=%0 has no e

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
delcypher wrote: @MaskRay > The current -fsanitize-trap behavior is intentional. See https://discourse.llvm.org/t/clang-gsoc-2025-usability-improvements-for-trapping-undefined-behavior-sanitizer/84568/11 Yes we aware the current behavior is intentional. That however doesn't mean it's the right

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/147997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/147997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-11 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/147997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-10 Thread Dan Liew via cfe-commits
delcypher wrote: @PiJoules > This might be a bit orthogonal to this patch, but I think rather than using > the mangled dollar scheme used by `__builtin_verbose_trap` to encode the > UBSan description, it might be cleaner to instead use dwarf's > `DW_AT_description` to actually store the UBSa

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-10 Thread Dan Liew via cfe-commits
delcypher wrote: @PiJoules > There's a large number of tests. Many of these look like they're close to an > existing test ... in these cases is it possible to just use the existing test > file and add checks under a prefix? I originally recommended that @anthonyhatran write new tests so this

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-09 Thread Dan Liew via cfe-commits
delcypher wrote: @rapidsna @patrykstefanski @hnrklssn Adding you as reviewers just so you're aware that this change is being worked on and that it will likely impact the downstream Swift fork of Clang. https://github.com/llvm/llvm-project/pull/145967 ___

[clang] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-09 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/145967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)

2025-06-30 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. Looks like we need to fix a few more things. Did you resolve the issue with the existing test cases failing? https://github.com/llvm/llvm-project/pull/145967 ___ cfe-commits mailing

[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)

2025-06-30 Thread Dan Liew via cfe-commits
@@ -4051,6 +4139,14 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID]; + llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation(); + llvm::StringRef TrapMessage = GetUBSanTrapForHandler(CheckHandlerI

[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)

2025-06-30 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/145967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)

2025-06-30 Thread Dan Liew via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \ +// RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -emit-llvm %s -o - | FileCheck %s + +int add_overflow(int a, int b) { + r

[clang] [Clang] [CodeGen] UBSan Trap Reasons (PR #145967)

2025-06-30 Thread Dan Liew via cfe-commits
@@ -85,6 +85,94 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetUBSanTrapForHandler(SanitizerHandler ID) { + switch

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -4041,7 +4133,8 @@ void CodeGenFunction::EmitUnreachable(SourceLocation Loc) { void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, SanitizerHandler CheckHandlerID, -bool NoMerge) { +

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/143758 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: %clang -O0 -g -debug-info-kind=standalone -dwarf-version=5 -fsanitize=undefined \ delcypher wrote: @anthonyhatran We should probably use `%clang_cc1` instead as a lot of codegen tests do that. That by-passes the clang driver (which is

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
delcypher wrote: @anthonyhatran Here's an example for `SanitizerHandler::InvalidObjCCast` ``` // Build with -fsanitize=objc-cast -fsanitize-trap=objc-cast @interface NSFastEnumerationState @end #define NSUInteger unsigned int @interface NSArray +(NSArray*) arrayWithObjects: (id) first, ...; -

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
delcypher wrote: @anthonyhatran Here's an example for `SanitizerHandler::AlignmentAssumption` ``` #include int32_t* get_int(void) __attribute__((assume_aligned(16))); void retrieve_int(void) { int* i = get_int(); *i = 7; } ``` https://github.com/llvm/llvm-project/pull/143758 _

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -85,6 +85,92 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) { ---

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -85,6 +85,92 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) { + swit

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -4059,8 +4154,16 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, auto Call = TrapBB->begin(); assert(isa(Call) && "Expected call in trap BB"); -Call->applyMergedLocation(Call->getDebugLoc(), - Builder.getCurrentDebugLoca

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -85,6 +85,92 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) { + swit

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -4059,8 +4154,16 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, auto Call = TrapBB->begin(); assert(isa(Call) && "Expected call in trap BB"); -Call->applyMergedLocation(Call->getDebugLoc(), - Builder.getCurrentDebugLoca

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -85,6 +85,92 @@ enum VariableTypeDescriptorKind : uint16_t { //Miscellaneous Helper Methods //======// +static llvm::StringRef GetTrapMessageForHandler(SanitizerHandler ID) { + swit

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. Thanks for working on this. We're off to a good start. Once we have your test cases in a good shape we should look at the failing tests to figure out why they broke so we can fix them or adjust your implementation. https://gi

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/143758 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -0,0 +1,10 @@ +// RUN: %clang -O0 -g -debug-info-kind=standalone -dwarf-version=5 -fsanitize=undefined \ +// RUN: -fsanitize-trap=undefined -emit-llvm -S -c %s -o - | FileCheck %s + +int add_overflow(int a, int b) { + return a + b; +} + +// CHECK: call void @llvm.ubsantrap(i8

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -4051,6 +4144,14 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID]; + llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation(); + llvm::StringRef Category = GetTrapMessageForHandler(CheckHandlerID

[clang] [clang][CodeGen] Added SanitizerHandler mapping, trap messages in debug info, and corresponding test cases. (PR #143758)

2025-06-23 Thread Dan Liew via cfe-commits
@@ -4051,6 +4137,15 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID]; + llvm::DILocation *TrapLocation = Builder.getCurrentDebugLocation(); + llvm::StringRef Category = "UBSan Trap Reason"; d

[clang] [ubsan] Add more -fsanitize-annotate-debug-info checks (PR #141997)

2025-06-04 Thread Dan Liew via cfe-commits
delcypher wrote: @vitalybuka > > Should we just rename stuff of this patch into __clang_trap_msg ? > > Actually no. > > __clang_trap_msg_* is only for trap. __ubsan_check_* is for instructions > evaluating check (as now there is a bonus: that __ubsan_check_* works as > __clang_trap_msg_* on

[clang] [ubsan] Add more -fsanitize-annotate-debug-info checks (PR #141997)

2025-06-03 Thread Dan Liew via cfe-commits
delcypher wrote: @Michael137 Ping https://github.com/llvm/llvm-project/pull/141997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ubsan] Add more -fsanitize-annotate-debug-info checks (PR #141997)

2025-06-02 Thread Dan Liew via cfe-commits
delcypher wrote: @thurstond So there is a significant overlap here with what my GSoC student (@anthonyhatran) is working on right now (CC @MiB137). The project was proposed [here](https://llvm.org/OpenProjects.html#clang-improve-trapping-ubsan-2025). During @anthonyhatran 's GSoC project he wi

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-15 Thread Dan Liew via cfe-commits
@@ -2808,6 +2842,9 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T, Address Derived, if (!SanOpts.has(SanitizerKind::CFICastStrict)) ClassDecl = LeastDerivedClassWithSameLayout(ClassDecl); + auto [Ordinal, SSK] = ParseCFITypeCheckKind(TCK); --

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-15 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/139809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-15 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/139809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-15 Thread Dan Liew via cfe-commits
@@ -2779,13 +2779,47 @@ void CodeGenFunction::EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD, } } +std::pair +CodeGenFunction::ParseCFITypeCheckKind(CFITypeCheckKind TCK) { + SanitizerKind::SanitizerOrdinal M; + llvm::SanitizerStatKind SSK; + + switch (TCK) { + ca

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-15 Thread Dan Liew via cfe-commits
https://github.com/delcypher commented: Seems reasonable to me other than my coding style nits. I don't own this code though so you should wait for approval from one of the code owners. https://github.com/llvm/llvm-project/pull/139809 ___ cfe-commits

[clang] [cfi] Enable -fsanitize-annotate-debug-info functionality for CFI checks (PR #139809)

2025-05-15 Thread Dan Liew via cfe-commits
@@ -2779,13 +2779,47 @@ void CodeGenFunction::EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD, } } +std::pair +CodeGenFunction::ParseCFITypeCheckKind(CFITypeCheckKind TCK) { + SanitizerKind::SanitizerOrdinal M; + llvm::SanitizerStatKind SSK; + + switch (TCK) { + ca

[clang] [sanitizer] Add plumbing for -fsanitize-add-pseudo-functions and partly replace '-mllvm -array-bounds-pseudofn' (PR #138577)

2025-05-05 Thread Dan Liew via cfe-commits
@@ -2533,6 +2533,31 @@ def fno_sanitize_merge_handlers : Flag<["-"], "fno-sanitize-merge">, Group, AliasArgs<["all"]>, Visibility<[ClangOption, CLOption]>, HelpText<"Do not allow compiler to merge handlers for any sanitizers">;

[clang] [sanitizer] Add plumbing for -fsanitize-add-pseudo-functions and partly replace '-mllvm -array-bounds-pseudofn' (PR #138577)

2025-05-05 Thread Dan Liew via cfe-commits
@@ -2533,6 +2533,31 @@ def fno_sanitize_merge_handlers : Flag<["-"], "fno-sanitize-merge">, Group, AliasArgs<["all"]>, Visibility<[ClangOption, CLOption]>, HelpText<"Do not allow compiler to merge handlers for any sanitizers">;

[clang] [sanitizer] Add plumbing for -fsanitize-add-pseudo-functions and partly replace '-mllvm -array-bounds-pseudofn' (PR #138577)

2025-05-05 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited https://github.com/llvm/llvm-project/pull/138577 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [sanitizer] Add plumbing for -fsanitize-add-pseudo-functions and partly replace '-mllvm -array-bounds-pseudofn' (PR #138577)

2025-05-05 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. Seems reasonable. My main issue is the "add pseudo functions" name which isn't clear and isn't documented. https://github.com/llvm/llvm-project/pull/138577 ___ cfe-commits mailing li

[clang] [C] Warn on uninitialized const objects (PR #137166)

2025-05-01 Thread Dan Liew via cfe-commits
@@ -8197,6 +8197,16 @@ def err_address_space_qualified_new : Error< def err_address_space_qualified_delete : Error< "'delete' cannot delete objects of type %0 in address space '%1'">; +def note_default_init_const_member : Note< + "member %0 declared 'const' here">; +def war

[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)

2025-04-18 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed https://github.com/llvm/llvm-project/pull/106321 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)

2025-04-18 Thread Dan Liew via cfe-commits
delcypher wrote: I had to tweak some minor issues with the diagnostic text that I discovered when trying to cherry pick this into our fork. I've fixed them and I'm going to land this now. https://github.com/llvm/llvm-project/pull/106321 ___ cfe-commi

[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)

2025-04-15 Thread Dan Liew via cfe-commits
delcypher wrote: > I think this should be fine at this point. I’m having a bit of a hard time > trying to figure out what changed since my last review because of the > force-pushing, but so long as you haven’t made any other major changes since > then then this ltgm now. Sorry about that. Thi

  1   2   3   4   5   >