diff options
author | Oliver Hunt <oliver@apple.com> | 2025-08-18 13:29:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-18 20:29:26 +0000 |
commit | 624b724ca6df5d2d3ea16b9ed232851e5d061be4 (patch) | |
tree | 3e141236801ca4487dc5f9bedd2f2e0e81254fd8 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 9617ce4862cf0ed5257699348f369eb179f119e9 (diff) | |
download | llvm-624b724ca6df5d2d3ea16b9ed232851e5d061be4.zip llvm-624b724ca6df5d2d3ea16b9ed232851e5d061be4.tar.gz llvm-624b724ca6df5d2d3ea16b9ed232851e5d061be4.tar.bz2 |
[clang][PAC] ptrauth_qualifier and ptrauth_intrinsic should only be available on Darwin (#153912)
For backwards compatibility reasons the `ptrauth_qualifier` and
`ptrauth_intrinsic` features need to be testable with `__has_feature()`
on Apple platforms, but for other platforms this backwards compatibility
issue does not exist.
This PR resolves these issues by making the `ptrauth_qualifier` and
`ptrauth_intrinsic` tests conditional upon a darwin target. This also
allows us to revert the ptrauth_qualifier check from an extension to a
feature test again, as is required on these platforms.
At the same time we introduce a new predefined macro `__PTRAUTH__` that
answers the same question as `__has_feature(ptrauth_qualifier)` and
`__has_feature(ptrauth_intrinsic)` as those tests are synonymous and
only exist separately for compatibility reasons.
The requirement to test for the `__PTRAUTH__` macro also resolves the
hazard presented by mixing the `ptrauth_qualifier` flag (that impacts
ABI and security policies) with `-pedantics-errors`, which makes
`__has_extension` return false for all extensions.
---------
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 5980806..4865c0b 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1535,6 +1535,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI, #undef TARGET_OS } + if (LangOpts.PointerAuthIntrinsics) + Builder.defineMacro("__PTRAUTH__"); + // Get other target #defines. TI.getTargetDefines(LangOpts, Builder); } |