[clang] 1301cf4 - [PAC][clang] Enhance preprocessor ptrauth tests (#98862)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 12:27:56 PDT 2024


Author: Daniil Kovalev
Date: 2024-07-15T22:27:52+03:00
New Revision: 1301cf486639c31353b2eede4596f3216c0d49ea

URL: https://github.com/llvm/llvm-project/commit/1301cf486639c31353b2eede4596f3216c0d49ea
DIFF: https://github.com/llvm/llvm-project/commit/1301cf486639c31353b2eede4596f3216c0d49ea.diff

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

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

Added: 
    

Modified: 
    clang/test/Preprocessor/ptrauth_feature.c

Removed: 
    


################################################################################
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


        


More information about the cfe-commits mailing list