[clang] Implement src:*=sanitize for UBSan (PR #139772)

Qinkun Bao via cfe-commits cfe-commits at lists.llvm.org
Wed May 14 07:50:27 PDT 2025


================
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck %s -check-prefix=CHECK-ALLOWLIST
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck %s -check-prefix=CHECK-IGNORELIST
+
+
+// Verify ubsan only emits checks for files in the allowlist
+
+//--- src.ignorelist
+src:*
----------------
qinkunbao wrote:

> Looks like we have a problem with:
>```
>src:*
>src:*/mylib/*=sanitize
>src:*/mylib/test.cc
> ```

Yeah, I was a little hesitated about the change during implementing the feature. For example, if we have a ignore list file

```
type:int
src:test.cc=sanitize
```
If a file `test.cc` has the type `int`, shall we still instrument the type `int` variable in the file `test.cc`?

On the other hand,

```
src:test.cc
type:int=sanitize
```
Shall we still instrument the type `int` variable in the file `test.cc`?

I think the both answers are yes.

Looks like if we have two lines that contradict each other, we should always stick to the `=sanitize` entry. It makes sense to me. I will create a new PR with using user branches in llvm/llvm-project to update `SpecialCaseList::Sections`. Thank you for the feedback.



https://github.com/llvm/llvm-project/pull/139772


More information about the cfe-commits mailing list