[clang] [clang][PAC] Add ptrauth.h helpers for computing type discriminators (PR #163456)

Daniil Kovalev via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 14 17:31:42 PDT 2025


================
@@ -592,6 +592,36 @@ The result value is never zero and always within range for both the
 
 This can be used in constant expressions.
 
+``ptrauth_type_discriminator``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: c
+
+  ptrauth_type_discriminator(type)
+
+Compute the constant discriminator derived from the given type, as is computed
+for automatically type diversified schemas.
+
+``type`` must be a type. The result has the type ``ptrauth_extra_data_t``.
+
+This can be used in constant expressions.
+
+``ptrauth_function_pointer_type_discriminator``
----------------
kovdan01 wrote:

Nit: maybe `ptrauth_function_pointer_discriminator` (w/o type) would suite better here? We either have a type-based discriminator if the feature is requested or just have zero, so it might be better to call the macro just `ptrauth_function_pointer_discriminator` w/o making the user think that it's a type discriminator.

Totally optional and feel free to ignore.

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


More information about the cfe-commits mailing list