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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 5 08:33:40 PDT 2025


================
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -fsanitize=kcfi -verify %s
+
+#define __cfi_salt(S) __attribute__((cfi_salt(S)))
+
+int bad1() __cfi_salt(); // expected-error{{'cfi_salt' attribute takes one argument}}
+int bad2() __cfi_salt(42); // expected-error{{expected string literal as argument of 'cfi_salt' attribute}}
+int bad3() __attribute__((cfi_salt("a", "b", "c"))); // expected-error{{'cfi_salt' attribute takes one argument}}
----------------
AaronBallman wrote:

```suggestion
int bad1(void) __cfi_salt(); // expected-error{{'cfi_salt' attribute takes one argument}}
int bad2(void) __cfi_salt(42); // expected-error{{expected string literal as argument of 'cfi_salt' attribute}}
int bad3(void) __attribute__((cfi_salt("a", "b", "c"))); // expected-error{{'cfi_salt' attribute takes one argument}}
```
This makes it more clear as to what's being tested (it's not the function prototype that matters for these tests, it's the attribute argument list).

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


More information about the cfe-commits mailing list