[libcxx-commits] [libcxx] 97d60af - [libc++] Renames nasty_macro test.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 26 14:18:15 PDT 2023
Author: Mark de Wever
Date: 2023-07-26T23:18:09+02:00
New Revision: 97d60af0d33bfa7643311141f2c964f5d6ff728e
URL: https://github.com/llvm/llvm-project/commit/97d60af0d33bfa7643311141f2c964f5d6ff728e
DIFF: https://github.com/llvm/llvm-project/commit/97d60af0d33bfa7643311141f2c964f5d6ff728e.diff
LOG: [libc++] Renames nasty_macro test.
The name is not really descriptive, renamed the file and improved the
diagnostics.
As a drive-by fixes one macro to generate a diagnostic.
Reviewed By: #libc, jloser, philnik
Differential Revision: https://reviews.llvm.org/D156051
Added:
libcxx/test/libcxx/system_reserved_names.gen.py
Modified:
Removed:
libcxx/test/libcxx/nasty_macros.gen.py
################################################################################
diff --git a/libcxx/test/libcxx/nasty_macros.gen.py b/libcxx/test/libcxx/nasty_macros.gen.py
deleted file mode 100644
index fdc308416f3418..00000000000000
--- a/libcxx/test/libcxx/nasty_macros.gen.py
+++ /dev/null
@@ -1,158 +0,0 @@
-#===----------------------------------------------------------------------===##
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-#===----------------------------------------------------------------------===##
-
-# Test that headers are not tripped up by the surrounding code defining various
-# alphabetic macros.
-
-# RUN: %{python} %s %{libcxx}/utils
-
-import sys
-sys.path.append(sys.argv[1])
-from libcxx.test.header_information import lit_header_restrictions, public_headers
-
-for header in public_headers:
- print(f"""\
-//--- {header}.compile.pass.cpp
-{lit_header_restrictions.get(header, '')}
-
-#define NASTY_MACRO This should not be expanded!!!
-
-// libc++ does not use single-letter names as a matter of principle.
-// But Windows' own <wchar.h>, <math.h>, and <exception> use many of these
-// (at least C,E,F,I,M,N,P,S,X,Y,Z) as uglified function parameter names,
-// so don't define these on Windows.
-//
-#ifndef _WIN32
-#define _A NASTY_MACRO
-#define _B NASTY_MACRO
-#define _C NASTY_MACRO
-#define _D NASTY_MACRO
-#define _E NASTY_MACRO
-#define _F NASTY_MACRO
-#define _G NASTY_MACRO
-#define _H NASTY_MACRO
-#define _I NASTY_MACRO
-#define _J NASTY_MACRO
-#define _K NASTY_MACRO
-#define _L NASTY_MACRO
-#define _M NASTY_MACRO
-#define _N NASTY_MACRO
-#define _O NASTY_MACRO
-#define _P NASTY_MACRO
-#define _Q NASTY_MACRO
-#define _R NASTY_MACRO
-#define _S NASTY_MACRO
-#define _T NASTY_MACRO
-#define _U NASTY_MACRO
-#define _V NASTY_MACRO
-#define _W NASTY_MACRO
-#define _X NASTY_MACRO
-#define _Y NASTY_MACRO
-#define _Z NASTY_MACRO
-#endif
-
-// FreeBSD's <sys/types.h> uses _M
-//
-#ifdef __FreeBSD__
-# undef _M
-#endif
-
-// Test that libc++ doesn't use names that collide with FreeBSD system macros.
-#ifndef __FreeBSD__
-# define __null_sentinel NASTY_MACRO
-# define __generic
-#endif
-
-// tchar.h defines these macros on Windows
-#ifndef _WIN32
-# define _UI NASTY_MACRO
-# define _PUC NASTY_MACRO
-# define _CPUC NASTY_MACRO
-# define _PC NASTY_MACRO
-# define _CRPC NASTY_MACRO
-# define _CPC NASTY_MACRO
-#endif
-
-// yvals.h on MINGW defines this macro
-#ifndef _WIN32
-# define _C2 NASTY_MACRO
-#endif
-
-// Test that libc++ doesn't use names that collide with Win32 API macros.
-// Obviously we can only define these on non-Windows platforms.
-#ifndef _WIN32
-# define __allocator NASTY_MACRO
-# define __bound NASTY_MACRO
-# define __deallocate NASTY_MACRO
-# define __deref NASTY_MACRO
-# define __format_string NASTY_MACRO
-# define __full NASTY_MACRO
-# define __in NASTY_MACRO
-# define __inout NASTY_MACRO
-# define __nz NASTY_MACRO
-# define __out NASTY_MACRO
-# define __part NASTY_MACRO
-# define __post NASTY_MACRO
-# define __pre NASTY_MACRO
-#endif
-
-#define __input NASTY_MACRO
-#define __output NASTY_MACRO
-
-#define __acquire NASTY_MACRO
-#define __release NASTY_MACRO
-
-// These names are not reserved, so the user can macro-define them.
-// These are intended to find improperly _Uglified template parameters.
-#define A NASTY_MACRO
-#define Arg NASTY_MACRO
-#define Args NASTY_MACRO
-#define As NASTY_MACRO
-#define B NASTY_MACRO
-#define Bs NASTY_MACRO
-#define C NASTY_MACRO
-#define Cp NASTY_MACRO
-#define Cs NASTY_MACRO
-// Windows setjmp.h contains a struct member named 'D' on ARM/AArch64.
-#ifndef _WIN32
-# define D NASTY_MACRO
-#endif
-#define Dp NASTY_MACRO
-#define Ds NASTY_MACRO
-#define E NASTY_MACRO
-#define Ep NASTY_MACRO
-#define Es NASTY_MACRO
-#define R NASTY_MACRO
-#define Rp NASTY_MACRO
-#define Rs NASTY_MACRO
-#define T NASTY_MACRO
-#define Tp NASTY_MACRO
-#define Ts NASTY_MACRO
-#define Type NASTY_MACRO
-#define Types NASTY_MACRO
-#define U NASTY_MACRO
-#define Up NASTY_MACRO
-#define Us NASTY_MACRO
-#define V NASTY_MACRO
-#define Vp NASTY_MACRO
-#define Vs NASTY_MACRO
-#define X NASTY_MACRO
-#define Xp NASTY_MACRO
-#define Xs NASTY_MACRO
-
-// The classic Windows min/max macros
-#define min NASTY_MACRO
-#define max NASTY_MACRO
-
-// Test to make sure curses has no conflicting macros with the standard library
-#define move NASTY_MACRO
-#define erase NASTY_MACRO
-#define refresh NASTY_MACRO
-
-#include <{header}>
-""")
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
new file mode 100644
index 00000000000000..68d74014c39d66
--- /dev/null
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -0,0 +1,158 @@
+#===----------------------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+# Test that headers are not tripped up by the surrounding code defining various
+# alphabetic macros.
+
+# RUN: %{python} %s %{libcxx}/utils
+
+import sys
+sys.path.append(sys.argv[1])
+from libcxx.test.header_information import lit_header_restrictions, public_headers
+
+for header in public_headers:
+ print(f"""\
+//--- {header}.compile.pass.cpp
+{lit_header_restrictions.get(header, '')}
+
+#define SYSTEM_RESERVED_NAME This name should not be used in libc++
+
+// libc++ does not use single-letter names as a matter of principle.
+// But Windows' own <wchar.h>, <math.h>, and <exception> use many of these
+// (at least C,E,F,I,M,N,P,S,X,Y,Z) as uglified function parameter names,
+// so don't define these on Windows.
+//
+#ifndef _WIN32
+#define _A SYSTEM_RESERVED_NAME
+#define _B SYSTEM_RESERVED_NAME
+#define _C SYSTEM_RESERVED_NAME
+#define _D SYSTEM_RESERVED_NAME
+#define _E SYSTEM_RESERVED_NAME
+#define _F SYSTEM_RESERVED_NAME
+#define _G SYSTEM_RESERVED_NAME
+#define _H SYSTEM_RESERVED_NAME
+#define _I SYSTEM_RESERVED_NAME
+#define _J SYSTEM_RESERVED_NAME
+#define _K SYSTEM_RESERVED_NAME
+#define _L SYSTEM_RESERVED_NAME
+#define _M SYSTEM_RESERVED_NAME
+#define _N SYSTEM_RESERVED_NAME
+#define _O SYSTEM_RESERVED_NAME
+#define _P SYSTEM_RESERVED_NAME
+#define _Q SYSTEM_RESERVED_NAME
+#define _R SYSTEM_RESERVED_NAME
+#define _S SYSTEM_RESERVED_NAME
+#define _T SYSTEM_RESERVED_NAME
+#define _U SYSTEM_RESERVED_NAME
+#define _V SYSTEM_RESERVED_NAME
+#define _W SYSTEM_RESERVED_NAME
+#define _X SYSTEM_RESERVED_NAME
+#define _Y SYSTEM_RESERVED_NAME
+#define _Z SYSTEM_RESERVED_NAME
+#endif
+
+// FreeBSD's <sys/types.h> uses _M
+//
+#ifdef __FreeBSD__
+# undef _M
+#endif
+
+// Test that libc++ doesn't use names that collide with FreeBSD system macros.
+#ifndef __FreeBSD__
+# define __null_sentinel SYSTEM_RESERVED_NAME
+# define __generic SYSTEM_RESERVED_NAME
+#endif
+
+// tchar.h defines these macros on Windows
+#ifndef _WIN32
+# define _UI SYSTEM_RESERVED_NAME
+# define _PUC SYSTEM_RESERVED_NAME
+# define _CPUC SYSTEM_RESERVED_NAME
+# define _PC SYSTEM_RESERVED_NAME
+# define _CRPC SYSTEM_RESERVED_NAME
+# define _CPC SYSTEM_RESERVED_NAME
+#endif
+
+// yvals.h on MINGW defines this macro
+#ifndef _WIN32
+# define _C2 SYSTEM_RESERVED_NAME
+#endif
+
+// Test that libc++ doesn't use names that collide with Win32 API macros.
+// Obviously we can only define these on non-Windows platforms.
+#ifndef _WIN32
+# define __allocator SYSTEM_RESERVED_NAME
+# define __bound SYSTEM_RESERVED_NAME
+# define __deallocate SYSTEM_RESERVED_NAME
+# define __deref SYSTEM_RESERVED_NAME
+# define __format_string SYSTEM_RESERVED_NAME
+# define __full SYSTEM_RESERVED_NAME
+# define __in SYSTEM_RESERVED_NAME
+# define __inout SYSTEM_RESERVED_NAME
+# define __nz SYSTEM_RESERVED_NAME
+# define __out SYSTEM_RESERVED_NAME
+# define __part SYSTEM_RESERVED_NAME
+# define __post SYSTEM_RESERVED_NAME
+# define __pre SYSTEM_RESERVED_NAME
+#endif
+
+#define __input SYSTEM_RESERVED_NAME
+#define __output SYSTEM_RESERVED_NAME
+
+#define __acquire SYSTEM_RESERVED_NAME
+#define __release SYSTEM_RESERVED_NAME
+
+// These names are not reserved, so the user can macro-define them.
+// These are intended to find improperly _Uglified template parameters.
+#define A SYSTEM_RESERVED_NAME
+#define Arg SYSTEM_RESERVED_NAME
+#define Args SYSTEM_RESERVED_NAME
+#define As SYSTEM_RESERVED_NAME
+#define B SYSTEM_RESERVED_NAME
+#define Bs SYSTEM_RESERVED_NAME
+#define C SYSTEM_RESERVED_NAME
+#define Cp SYSTEM_RESERVED_NAME
+#define Cs SYSTEM_RESERVED_NAME
+// Windows setjmp.h contains a struct member named 'D' on ARM/AArch64.
+#ifndef _WIN32
+# define D SYSTEM_RESERVED_NAME
+#endif
+#define Dp SYSTEM_RESERVED_NAME
+#define Ds SYSTEM_RESERVED_NAME
+#define E SYSTEM_RESERVED_NAME
+#define Ep SYSTEM_RESERVED_NAME
+#define Es SYSTEM_RESERVED_NAME
+#define R SYSTEM_RESERVED_NAME
+#define Rp SYSTEM_RESERVED_NAME
+#define Rs SYSTEM_RESERVED_NAME
+#define T SYSTEM_RESERVED_NAME
+#define Tp SYSTEM_RESERVED_NAME
+#define Ts SYSTEM_RESERVED_NAME
+#define Type SYSTEM_RESERVED_NAME
+#define Types SYSTEM_RESERVED_NAME
+#define U SYSTEM_RESERVED_NAME
+#define Up SYSTEM_RESERVED_NAME
+#define Us SYSTEM_RESERVED_NAME
+#define V SYSTEM_RESERVED_NAME
+#define Vp SYSTEM_RESERVED_NAME
+#define Vs SYSTEM_RESERVED_NAME
+#define X SYSTEM_RESERVED_NAME
+#define Xp SYSTEM_RESERVED_NAME
+#define Xs SYSTEM_RESERVED_NAME
+
+// The classic Windows min/max macros
+#define min SYSTEM_RESERVED_NAME
+#define max SYSTEM_RESERVED_NAME
+
+// Test to make sure curses has no conflicting macros with the standard library
+#define move SYSTEM_RESERVED_NAME
+#define erase SYSTEM_RESERVED_NAME
+#define refresh SYSTEM_RESERVED_NAME
+
+#include <{header}>
+""")
More information about the libcxx-commits
mailing list