[PATCH] D114576: [PR52549][clang-cl] Predefine _MSVC_EXECUTION_CHARACTER_SET

Markus Böck via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 27 04:38:06 PST 2021


zero9178 updated this revision to Diff 390156.
zero9178 added a comment.

Alternative implementation of the original patch.

Moves the defining macro from being added to the cc1 command line by the driver, to being a builtin macro. This should avoid the issues with clang-tidy.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114576/new/

https://reviews.llvm.org/D114576

Files:
  clang/lib/Basic/Targets/OSTargets.cpp
  clang/test/Preprocessor/init.c


Index: clang/test/Preprocessor/init.c
===================================================================
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -194,6 +194,7 @@
 // MSEXT:#define _INTEGRAL_MAX_BITS 64
 // MSEXT-NOT:#define _NATIVE_WCHAR_T_DEFINED 1
 // MSEXT-NOT:#define _WCHAR_T_DEFINED 1
+// MSEXT:#define _MSVC_EXECUTION_CHARACTER_SET 65001
 //
 //
 // RUN: %clang_cc1 -x c++ -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT-CXX %s
Index: clang/lib/Basic/Targets/OSTargets.cpp
===================================================================
--- clang/lib/Basic/Targets/OSTargets.cpp
+++ clang/lib/Basic/Targets/OSTargets.cpp
@@ -201,6 +201,14 @@
   }
 
   Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
+
+  // 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
+  Builder.defineMacro("_MSVC_EXECUTION_CHARACTER_SET", "65001");
 }
 
 void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114576.390156.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211127/170b64a8/attachment.bin>


More information about the cfe-commits mailing list