[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 2 13:12:07 PDT 2018


mstorsjo updated this revision to Diff 158827.
mstorsjo added a comment.

Simplified the patch to just handle the flag within the driver, without making it a flag to cc1.


https://reviews.llvm.org/D50199

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mingw.cpp


Index: test/Driver/mingw.cpp
===================================================================
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -56,3 +56,8 @@
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}5.3-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}5.3-posix{{/|\\\\}}include{{/|\\\\}}c++{{/|\\\\}}backward"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|\\\\}}x86_64-w64-mingw32{{/|\\\\}}include"
+
+// RUN: %clang -target i686-windows-gnu -E -### %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_NO_UNICODE %s
+// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UNICODE %s
+// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
+// CHECK_MINGW_UNICODE: "-DUNICODE"
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3346,6 +3346,9 @@
   if (Args.hasArg(options::OPT_static))
     CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+    CmdArgs.push_back("-DUNICODE");
+
   if (isa<AnalyzeJobAction>(JA))
     RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50199.158827.patch
Type: text/x-patch
Size: 1471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180802/cb47251d/attachment.bin>


More information about the cfe-commits mailing list