[clang] 1dbc8ef - [clang][ptrauth] Make ptrauth feature detection tests more robust (#136204)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 17 17:53:37 PDT 2025
Author: Oliver Hunt
Date: 2025-04-17T17:53:34-07:00
New Revision: 1dbc8ef5538e25f61664d807fda236f7d983cc69
URL: https://github.com/llvm/llvm-project/commit/1dbc8ef5538e25f61664d807fda236f7d983cc69
DIFF: https://github.com/llvm/llvm-project/commit/1dbc8ef5538e25f61664d807fda236f7d983cc69.diff
LOG: [clang][ptrauth] Make ptrauth feature detection tests more robust (#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.
Added:
Modified:
clang/test/Sema/ptrauth-qualifier.c
clang/test/Sema/ptrauth.c
clang/test/SemaObjC/ptrauth-qualifier.m
Removed:
################################################################################
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