[PATCH] D114576: [PR52549][clang-cl] Predefine _MSVC_EXECUTION_CHARACTER_SET
Markus Böck via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 25 02:23:34 PST 2021
zero9178 updated this revision to Diff 389698.
zero9178 added a comment.
Enable the macro for all MSVC targets, regardless of driver in use.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114576/new/
https://reviews.llvm.org/D114576
Files:
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-execution-character-set.c
Index: clang/test/Driver/cl-execution-character-set.c
===================================================================
--- /dev/null
+++ clang/test/Driver/cl-execution-character-set.c
@@ -0,0 +1,14 @@
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// Only UTF-8 is currently supported, which has the Windows Code
+// Page Identifier 65001
+
+// Check this works with the clang-cl driver as well as with the GNU clang driver
+// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-MSVC %s
+// RUN: %clang --target=x86_64-pc-windows-msvc -### %s 2>&1 | FileCheck -check-prefix=CHECK-MSVC %s
+// CHECK-MSVC: -D_MSVC_EXECUTION_CHARACTER_SET=65001
+
+// It shouldn't be defined for any non MSVC targets
+// RUN: %clang --target=x86_64-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK-NON-MSVC %s
+// CHECK-NON-MSVC-NOT: -D_MSVC_EXECUTION_CHARACTER_SET
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===================================================================
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -1609,4 +1609,12 @@
if (DriverArgs.hasArg(options::OPT_fno_rtti, options::OPT_frtti,
/*Default=*/false))
CC1Args.push_back("-D_HAS_STATIC_RTTI=0");
+
+ // Starting with VS 2022 17.1, MSVC predefines the below macro to inform
+ // users of the execution character set defined at compile time.
+ // The value given is the Windows Code Page Identifier:
+ // https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
+ //
+ // Clang currently only supports UTF-8, so we'll use 65001
+ CC1Args.push_back("-D_MSVC_EXECUTION_CHARACTER_SET=65001");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114576.389698.patch
Type: text/x-patch
Size: 1771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211125/2b33b11c/attachment.bin>
More information about the cfe-commits
mailing list