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

2025-07-23 Thread Anthony Tran via cfe-commits
@@ -0,0 +1,22 @@ +// FIXME: Currently, a nullptr check is in place before emitting a UBSan trap reason inside +// CodeGenFunction::EmitTrapCheck. This is disadvantageous because we may not emit a trap +// message in all cases where a trap message should be emitted. The check w

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

2025-07-14 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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] [WIP][DO NOT MERGE][Clang][Driver] Emit warning when -fsanitize-trap=<...> is passed without associated -fsanitize=<...> (PR #147997)

2025-07-14 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran updated https://github.com/llvm/llvm-project/pull/147997 >From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 10 Jul 2025 09:18:50 -0700 Subject: [PATCH 1/6] Added warning and warning group for sanitizer argument

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

2025-07-14 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran updated https://github.com/llvm/llvm-project/pull/147997 >From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 10 Jul 2025 09:18:50 -0700 Subject: [PATCH 1/5] Added warning and warning group for sanitizer argument

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

2025-07-14 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran updated https://github.com/llvm/llvm-project/pull/147997 >From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 10 Jul 2025 09:18:50 -0700 Subject: [PATCH 1/4] Added warning and warning group for sanitizer argument

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

2025-07-14 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran updated https://github.com/llvm/llvm-project/pull/147997 >From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 10 Jul 2025 09:18:50 -0700 Subject: [PATCH 1/3] Added warning and warning group for sanitizer argument

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

2025-07-11 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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 Anthony Tran 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 Anthony Tran 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] [Clang][CodeGen] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Anthony Tran via cfe-commits
@@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \ +// RUN: -fsanitize=return -fsanitize-trap=return -emit-llvm %s -o - | FileCheck %s + +int missing_return(int x) +{ +if (x > 0) +return x; +}

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

2025-07-11 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-11 Thread Anthony Tran via cfe-commits
@@ -68,9 +68,9 @@ double f1(int b, int i) { //. // CHECK-TRAP: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) -// CHEC

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

2025-07-11 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran deleted 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-11 Thread Anthony Tran via cfe-commits
@@ -17,8 +18,11 @@ void bar(volatile int a) __attribute__((optnone)) { } // With optimisations enabled the traps are merged and need to share a debug location -// CHECK: [[LOC]] = !DILocation(line: 0 +// CHECK: [[LOC]] = !DILocation(line: 0, anthonyhatran wro

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

2025-07-11 Thread Anthony Tran via cfe-commits
@@ -87,38 +87,42 @@ void baz(void (*fn)(int, int, int), int arg1, int arg2, int arg3) { // CHECK: [[DBG24]] = !DILocation(line: 25, column: 5, scope: [[DBG7]]) // CHECK: [[META25]] = !{} // CHECK: [[PROF26]] = !{!"branch_weights", i32 1048575, i32 1} -// CHECK: [[DBG27]] = !DI

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

2025-07-11 Thread Anthony Tran via cfe-commits
@@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \ +// RUN: -fsanitize=nullability-return -fsanitize-trap=nullability-return -emit-llvm %s -o - | FileCheck %s + +#include +#include + +int* _Nonnull nullabili

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

2025-07-11 Thread Anthony Tran via cfe-commits
@@ -17,8 +18,11 @@ void bar(volatile int a) __attribute__((optnone)) { } // With optimisations enabled the traps are merged and need to share a debug location -// CHECK: [[LOC]] = !DILocation(line: 0 +// CHECK: [[LOC]] = !DILocation(line: 0, anthonyhatran wro

[clang] [Clang][Driver] Emit warning when -fsanitize-trap=undefined is passed without -fsanitize=undefined (PR #147997)

2025-07-10 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran updated https://github.com/llvm/llvm-project/pull/147997 >From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 10 Jul 2025 09:18:50 -0700 Subject: [PATCH 1/2] Added warning and warning group for sanitizer argument

[clang] [Clang][Driver] Emit warning when -fsanitize-trap=undefined is passed without -fsanitize=undefined (PR #147997)

2025-07-10 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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][Driver] Emit warning when -fsanitize-trap=undefined is passed without -fsanitize=undefined (PR #147997)

2025-07-10 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran created https://github.com/llvm/llvm-project/pull/147997 Part of a GSoC 2025 Project >From eadf3e52072fbae01e8de8f7f59883aec1b2c9bc Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 10 Jul 2025 09:18:50 -0700 Subject: [PATCH] Added warning and warning gro

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

2025-07-08 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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] Emit “trap reasons” on UBSan traps (PR #145967)

2025-07-08 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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-07-03 Thread Anthony Tran via cfe-commits
anthonyhatran wrote: Commit #3 (338505e) Update: Apologies for taking a bit on the commit, took a while to fix test cases. I'll list how the 5 test cases were fixed below: 1. {`clang/test/CodeGen/ubsan-trap-debugloc.c`}: Hand written, so I adjusted the unmerged trap checks to expect a syntheti

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

2025-07-03 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran updated https://github.com/llvm/llvm-project/pull/145967 >From b7a68efce92eafcfb05e0fc9763303dc85fb4c78 Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 26 Jun 2025 12:40:05 -0700 Subject: [PATCH 1/3] Addressed most of Dan's comments and added remaining te

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

2025-07-01 Thread Anthony Tran via cfe-commits
anthonyhatran wrote: > Looks like we need to fix a few more things. Did you resolve the issue with > the existing test cases failing? Apologies for the belated reply on this one; I ran the test suite overnight just to double-check that the test cases I listed were actually caused by my change

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

2025-06-30 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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 Anthony Tran 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 Anthony Tran 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-26 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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-26 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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-26 Thread Anthony Tran via cfe-commits
anthonyhatran wrote: Anyways, to address Dan's comments, I changed all test cases so that they utilize `clang_cc1` instead of `clang`. This also meant that I had to change any `-fsanitize=undefined` and `-fsanitize-trap=undefined` to the specific check since `undefined` is a check grouping and

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

2025-06-26 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran 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] Gsoc ubsan trap reason v2 (PR #145967)

2025-06-26 Thread Anthony Tran via cfe-commits
https://github.com/anthonyhatran created https://github.com/llvm/llvm-project/pull/145967 None >From 7bdb672ef70687575b93d099ccfe261eec66d006 Mon Sep 17 00:00:00 2001 From: Anthony Tran Date: Thu, 26 Jun 2025 12:40:05 -0700 Subject: [PATCH 1/2] Addressed most of Dan's comments and added remain