[clang] [clang][ptrauth] Make ptrauth feature detection tests more robust (PR #136204)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 17 14:21:55 PDT 2025
https://github.com/ojhunt created https://github.com/llvm/llvm-project/pull/136204
The existing test behavior checked for a warning being emitted under an #if, but if the feature detection fails the #if fails and the warning is not expected in the output.
I've made the test more explicit, and added comments to ensure no one simply adds/moves any expected output around.
>From 83daa4fc0e86b234787a355612668ecbc0c473fd Mon Sep 17 00:00:00 2001
From: Oliver Hunt <oliver at apple.com>
Date: Thu, 17 Apr 2025 14:18:43 -0700
Subject: [PATCH] [clang][ptrauth] Make ptrauth feature detection tests more
robust
The existing test behavior checked for a warning being emitted under
an #if, but if the feature detection fails the #if fails and the
warning is not expected in the output.
I've made the test more explicit, and added comments to ensure no
one simply adds/moves any expected output around.
---
clang/test/Sema/ptrauth-qualifier.c | 8 +++++---
clang/test/Sema/ptrauth.c | 8 +++++---
clang/test/SemaObjC/ptrauth-qualifier.m | 8 +++++---
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/clang/test/Sema/ptrauth-qualifier.c b/clang/test/Sema/ptrauth-qualifier.c
index 99d16b062ca6f..ab12acd8975f4 100644
--- a/clang/test/Sema/ptrauth-qualifier.c
+++ b/clang/test/Sema/ptrauth-qualifier.c
@@ -1,9 +1,11 @@
// RUN: %clang_cc1 -triple arm64-apple-ios -std=c23 -fsyntax-only -verify -fptrauth-intrinsics %s
// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c23 -fsyntax-only -verify -fptrauth-intrinsics %s
-#if __has_feature(ptrauth_qualifier)
-#warning __ptrauth qualifier enabled!
-// expected-warning at -1 {{__ptrauth qualifier enabled!}}
+#if !__has_extension(ptrauth_qualifier)
+// This error means that the __ptrauth qualifier availability test says that it
+// is not available. This error is not expected in the output, if it is seen
+// there is a feature detection regression.
+#error __ptrauth qualifier not enabled
#endif
#if __aarch64__
diff --git a/clang/test/Sema/ptrauth.c b/clang/test/Sema/ptrauth.c
index fc1ae954fa36b..e3932615c2962 100644
--- a/clang/test/Sema/ptrauth.c
+++ b/clang/test/Sema/ptrauth.c
@@ -1,8 +1,10 @@
// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter
-#if __has_feature(ptrauth_intrinsics)
-#warning Pointer authentication enabled!
-// expected-warning at -1 {{Pointer authentication enabled!}}
+#if !__has_feature(ptrauth_intrinsics)
+// This error means that the __ptrauth intrinsics availability test says that
+// they are not available. This error is not expected in the output of this
+// test, if it is seen there is a feature detection regression.
+#error __ptrauth intrinsics not enabled
#endif
#if __aarch64__
diff --git a/clang/test/SemaObjC/ptrauth-qualifier.m b/clang/test/SemaObjC/ptrauth-qualifier.m
index 4836a653dd02f..98d0248f169be 100644
--- a/clang/test/SemaObjC/ptrauth-qualifier.m
+++ b/clang/test/SemaObjC/ptrauth-qualifier.m
@@ -1,9 +1,11 @@
// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics %s
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify -fptrauth-intrinsics %s
-#if __has_feature(ptrauth_qualifier)
-#warning __ptrauth qualifier enabled!
-// expected-warning at -1 {{__ptrauth qualifier enabled!}}
+#if !__has_extension(ptrauth_qualifier)
+// This error means that the __ptrauth qualifier availability test says that it
+// is not available. This error is not expected in the output, if it is seen
+// there is a feature detection regression.
+#error __ptrauth qualifier not enabled
#endif
@interface Foo
More information about the cfe-commits
mailing list