[clang] [PAC][clang] Enhance preprocessor ptrauth tests (PR #98862)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 14 23:59:37 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Daniil Kovalev (kovdan01)

<details>
<summary>Changes</summary>

Test one feature at a time to make RUN lines shorter. See also https://github.com/llvm/llvm-project/pull/96992#discussion_r1669394582

---
Full diff: https://github.com/llvm/llvm-project/pull/98862.diff


1 Files Affected:

- (modified) clang/test/Preprocessor/ptrauth_feature.c (+24-69) 


``````````diff
diff --git a/clang/test/Preprocessor/ptrauth_feature.c b/clang/test/Preprocessor/ptrauth_feature.c
index 88b6982c01657..1330ad10b4b47 100644
--- a/clang/test/Preprocessor/ptrauth_feature.c
+++ b/clang/test/Preprocessor/ptrauth_feature.c
@@ -1,69 +1,26 @@
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fptrauth-init-fini | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,CALLS,RETS,VPTR_ADDR_DISCR,VPTR_TYPE_DISCR,INITFINI,NOFUNC
+//// Note: preprocessor features exactly match corresponding clang driver flags. However, some flags are only intended to be used in combination with other ones.
+//// For example, -fptrauth-init-fini will not affect codegen without -fptrauth-calls, but the preprocessor feature would be set anyway.
 
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fptrauth-init-fini | \
-// RUN:   FileCheck %s --check-prefixes=NOINTRIN,CALLS,RETS,VPTR_ADDR_DISCR,VPTR_TYPE_DISCR,INITFINI,NOFUNC
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-intrinsics | \
+// RUN:   FileCheck %s --check-prefixes=INTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOFUNC,NOINITFINI
 
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fptrauth-init-fini | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,NOCALLS,RETS,VPTR_ADDR_DISCR,VPTR_TYPE_DISCR,INITFINI,NOFUNC
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-calls | \
+// RUN:   FileCheck %s --check-prefixes=NOINTRIN,CALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOFUNC,NOINITFINI
 
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fptrauth-init-fini | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,CALLS,NORETS,VPTR_ADDR_DISCR,VPTR_TYPE_DISCR,INITFINI,NOFUNC
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-returns | \
+// RUN:   FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,RETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOFUNC,NOINITFINI
 
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fptrauth-init-fini | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,CALLS,RETS,NOVPTR_ADDR_DISCR,VPTR_TYPE_DISCR,INITFINI,NOFUNC
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-vtable-pointer-address-discrimination | \
+// RUN:   FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,VPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOFUNC,NOINITFINI
 
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-init-fini | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,CALLS,RETS,VPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,INITFINI,NOFUNC
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-vtable-pointer-type-discrimination | \
+// RUN:   FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,VPTR_TYPE_DISCR,NOFUNC,NOINITFINI
 
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,CALLS,RETS,VPTR_ADDR_DISCR,VPTR_TYPE_DISCR,NOINITFINI,NOFUNC
-
-// RUN: %clang_cc1 -E %s -triple=aarch64 \
-// RUN:   -fptrauth-intrinsics \
-// RUN:   -fptrauth-calls \
-// RUN:   -fptrauth-returns \
-// RUN:   -fptrauth-vtable-pointer-address-discrimination \
-// RUN:   -fptrauth-vtable-pointer-type-discrimination \
-// RUN:   -fptrauth-function-pointer-type-discrimination | \
-// RUN:   FileCheck %s --check-prefixes=INTRIN,CALLS,RETS,VPTR_ADDR_DISCR,VPTR_TYPE_DISCR,NOINITFINI,FUNC
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-function-pointer-type-discrimination | \
+// RUN:   FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,FUNC,NOINITFINI
 
+// RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-init-fini | \
+// RUN:   FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOFUNC,INITFINI
 
 #if __has_feature(ptrauth_intrinsics)
 // INTRIN: has_ptrauth_intrinsics
@@ -114,16 +71,6 @@ void has_ptrauth_vtable_pointer_type_discrimination() {}
 void no_ptrauth_vtable_pointer_type_discrimination() {}
 #endif
 
-#if __has_feature(ptrauth_init_fini)
-// INITFINI: has_ptrauth_init_fini
-void has_ptrauth_init_fini() {}
-#else
-// NOINITFINI: no_ptrauth_init_fini
-void no_ptrauth_init_fini() {}
-#endif
-
-#include <ptrauth.h>
-
 #if __has_feature(ptrauth_function_pointer_type_discrimination)
 // FUNC: has_ptrauth_function_pointer_type_discrimination
 void has_ptrauth_function_pointer_type_discrimination() {}
@@ -131,3 +78,11 @@ void has_ptrauth_function_pointer_type_discrimination() {}
 // NOFUNC: no_ptrauth_function_pointer_type_discrimination
 void no_ptrauth_function_pointer_type_discrimination() {}
 #endif
+
+#if __has_feature(ptrauth_init_fini)
+// INITFINI: has_ptrauth_init_fini
+void has_ptrauth_init_fini() {}
+#else
+// NOINITFINI: no_ptrauth_init_fini
+void no_ptrauth_init_fini() {}
+#endif

``````````

</details>


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


More information about the cfe-commits mailing list