[llvm] [libcxx] [libc++][hardening] Rework macros for enabling the hardening mode. (PR #70575)

Louis Dionne via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 12:50:13 PDT 2023


================
@@ -6,48 +6,42 @@
 //
 //===----------------------------------------------------------------------===//
 
-// TODO: Remove these UNSUPPORTED lines once we change how hardening is enabled to avoid
-//       mutually exclusive modes being enabled at the same time.
-// UNSUPPORTED: libcpp-hardening-mode=hardened
-// UNSUPPORTED: libcpp-hardening-mode=safe
-// UNSUPPORTED: libcpp-hardening-mode=debug
-
 // TODO: Investigate
 // XFAIL: msvc
 
 // Test that we encode the hardening mode in an ABI tag to avoid ODR violations
 // when linking TUs that have different values for it.
 
-// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU1  -D_LIBCPP_ENABLE_HARDENED_MODE -o %t.tu1.o
-// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU2  -D_LIBCPP_ENABLE_SAFE_MODE     -o %t.tu2.o
-// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU3  -D_LIBCPP_ENABLE_DEBUG_MODE    -o %t.tu3.o
-// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU4                                 -o %t.tu4.o
-// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DMAIN                                -o %t.main.o
+// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU1  -Wno-macro-redefined -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST   -o %t.tu1.o
+// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU2  -Wno-macro-redefined -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_STRICT -o %t.tu2.o
+// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU3  -Wno-macro-redefined -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG  -o %t.tu3.o
+// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU4  -Wno-macro-redefined -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE   -o %t.tu4.o
+// RUN: %{cxx} %s %{flags} %{compile_flags} -c -DMAIN                                                                             -o %t.main.o
 // RUN: %{cxx} %t.tu1.o %t.tu2.o %t.tu3.o %t.tu4.o %t.main.o %{flags} %{link_flags} -o %t.exe
 // RUN: %{exec} %t.exe
 
-// hardened mode
+// fast hardening mode
 #ifdef TU1
 #  include <__config>
 _LIBCPP_HIDE_FROM_ABI inline int f() { return 1; }
 int tu1() { return f(); }
 #endif // TU1
 
-// safe mode
+// stricthardening mode
----------------
ldionne wrote:

```suggestion
// strict hardening mode
```

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


More information about the llvm-commits mailing list