[clang] [Clang][attr] Add 'kcfi_salt' attribute (PR #141846)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 14 10:50:34 PDT 2025


================
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -x c++ -o - %s | FileCheck %s --check-prefixes=CHECK,MEMBER
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi -fpatchable-function-entry-offset=3 -o - %s | FileCheck %s --check-prefixes=CHECK,OFFSET
+
+// Note that the interleving of functions, which normally would be in sequence,
+// is due to the fact that Clang outputs them in a non-sequential order.
+
+#if !__has_feature(kcfi)
----------------
AaronBallman wrote:

Oh, because this is a `DeclOrTypeAttr` we should also have sema tests for type mismatches, e.g.:
```
int func(void);
int (*fp)(void) [[clang::kcfi_salt("pepper")]] = func; // Is this okay?

int func2(void) [[clang::kcfi_salt("pepper")]];
int (*fp2)(void) = func2; // Is this okay?
```

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


More information about the cfe-commits mailing list