Author: compnerd
Date: Fri Oct  6 16:09:55 2017
New Revision: 315126

URL: http://llvm.org/viewvc/llvm-project?rev=315126&view=rev
Log:
Driver: hoist the `wchar_t` handling to the driver

Move the logic for determining the `wchar_t` type information into the
driver.  Rather than passing the single bit of information of
`-fshort-wchar` indicate to the frontend the desired type of `wchar_t`
through a new `-cc1` option of `-fwchar-type` and indicate the
signedness through `-f{,no-}signed-wchar`.  This replicates the current
logic which was spread throughout Basic into the
`RenderCharacterOptions`.

Most of the changes to the tests are to ensure that the frontend uses
the correct type.  Add a new test set under `test/Driver/wchar_t.c` to
ensure that we calculate the proper types for the various cases.

Added:
    cfe/trunk/test/Preprocessor/wchar_t.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
    cfe/trunk/include/clang/Basic/LangOptions.def
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/lib/Basic/Targets/AArch64.cpp
    cfe/trunk/lib/Basic/Targets/ARM.cpp
    cfe/trunk/lib/Basic/Targets/AVR.h
    cfe/trunk/lib/Basic/Targets/OSTargets.h
    cfe/trunk/lib/Basic/Targets/X86.h
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/test/CXX/conv/conv.prom/p2.cpp
    cfe/trunk/test/CodeGen/arm-metadata.c
    cfe/trunk/test/CodeGen/pascal-wchar-string.c
    cfe/trunk/test/CodeGen/string-literal-short-wstring.c
    cfe/trunk/test/CodeGen/string-literal-unicode-conversion.c
    cfe/trunk/test/CodeGen/wchar-size.c
    cfe/trunk/test/Driver/clang_f_opts.c
    cfe/trunk/test/Headers/wchar_limits.cpp
    cfe/trunk/test/Index/index-pch.cpp
    cfe/trunk/test/Lexer/wchar.c
    cfe/trunk/test/Preprocessor/init.c
    cfe/trunk/test/Preprocessor/pr19649-unsigned-wchar_t.c
    cfe/trunk/test/Sema/wchar.c
    cfe/trunk/test/SemaCXX/short-wchar-sign.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Oct  6 
16:09:55 2017
@@ -116,6 +116,8 @@ def err_fe_action_not_available : Error<
     "action %0 not compiled in">;
 def err_fe_invalid_alignment : Error<
     "invalid value '%1' in '%0'; alignment must be a power of 2">;
+def err_fe_invalid_wchar_type
+    : Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 
'int'">;
 
 def warn_fe_serialized_diag_merge_failure : Warning<
     "unable to merge a subprocess's serialized diagnostics">,

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Oct  6 16:09:55 2017
@@ -175,7 +175,8 @@ BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0,
 
 BENIGN_LANGOPT(AccessControl     , 1, 1, "C++ access control")
 LANGOPT(CharIsSigned      , 1, 1, "signed char")
-LANGOPT(ShortWChar        , 1, 0, "unsigned short wchar_t")
+LANGOPT(WCharSize         , 4, 0, "width of wchar_t")
+LANGOPT(WCharIsSigned        , 1, 0, "signed or unsigned wchar_t")
 ENUM_LANGOPT(MSPointerToMemberRepresentationMethod, 
PragmaMSPointersToMembersKind, 2, PPTMK_BestCase, "member-pointer 
representation method")
 ENUM_LANGOPT(DefaultCallingConv, DefaultCallingConvention, 3, DCC_None, 
"default calling convention")
 

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Oct  6 16:09:55 2017
@@ -709,6 +709,12 @@ def finclude_default_header : Flag<["-"]
   HelpText<"Include the default header file for OpenCL">;
 def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
   HelpText<"Preserve 3-component vector type">;
+def fwchar_type_EQ : Joined<["-"], "fwchar-type=">,
+  HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">;
+def fsigned_wchar : Flag<["-"], "fsigned-wchar">,
+  HelpText<"Use a signed type for wchar_t">;
+def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">,
+  HelpText<"Use an unsigned type for wchar_t">;
 
 // FIXME: Remove these entirely once functionality/tests have been excised.
 def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group<f_Group>,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Oct  6 16:09:55 2017
@@ -1382,9 +1382,9 @@ def frtti : Flag<["-"], "frtti">, Group<
 def : Flag<["-"], "fsched-interblock">, Group<clang_ignored_f_Group>;
 def fshort_enums : Flag<["-"], "fshort-enums">, Group<f_Group>, 
Flags<[CC1Option]>,
   HelpText<"Allocate to an enum type only as many bytes as it needs for the 
declared range of possible values">;
-def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>, 
Flags<[CC1Option]>,
+def fshort_wchar : Flag<["-"], "fshort-wchar">, Group<f_Group>,
   HelpText<"Force wchar_t to be a short unsigned int">;
-def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>, 
Flags<[CC1Option]>,
+def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group<f_Group>,
   HelpText<"Force wchar_t to be an unsigned int">;
 def fshow_overloads_EQ : Joined<["-"], "fshow-overloads=">, Group<f_Group>, 
Flags<[CC1Option]>,
   HelpText<"Which overload candidates to show when overload resolution fails: "

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Oct  6 16:09:55 2017
@@ -19,6 +19,7 @@
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/TargetParser.h"
 #include <cstdlib>
 using namespace clang;
 
@@ -290,8 +291,15 @@ bool TargetInfo::isTypeSigned(IntType T)
 void TargetInfo::adjust(LangOptions &Opts) {
   if (Opts.NoBitFieldTypeAlign)
     UseBitFieldTypeAlignment = false;
-  if (Opts.ShortWChar)
-    WCharType = UnsignedShort;
+
+  switch (Opts.WCharSize) {
+  default: llvm_unreachable("invalid wchar_t width");
+  case 0: break;
+  case 1: WCharType = Opts.WCharIsSigned ? SignedChar : UnsignedChar; break;
+  case 2: WCharType = Opts.WCharIsSigned ? SignedShort : UnsignedShort; break;
+  case 4: WCharType = Opts.WCharIsSigned ? SignedInt : UnsignedInt; break;
+  }
+
   if (Opts.AlignDouble) {
     DoubleAlign = LongLongAlign = 64;
     LongDoubleAlign = 64;

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Fri Oct  6 16:09:55 2017
@@ -15,6 +15,7 @@
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringExtras.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -34,18 +35,19 @@ AArch64TargetInfo::AArch64TargetInfo(con
     : TargetInfo(Triple), ABI("aapcs") {
   if (getTriple().getOS() == llvm::Triple::NetBSD ||
       getTriple().getOS() == llvm::Triple::OpenBSD) {
-    WCharType = SignedInt;
-
     // NetBSD apparently prefers consistency across ARM targets to
     // consistency across 64-bit targets.
     Int64Type = SignedLongLong;
     IntMaxType = SignedLongLong;
   } else {
-    WCharType = UnsignedInt;
+    if (!getTriple().isOSDarwin())
+      WCharType = UnsignedInt;
+
     Int64Type = SignedLong;
     IntMaxType = SignedLong;
   }
 
+
   LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
   MaxVectorAlign = 128;
   MaxAtomicInlineWidth = 128;
@@ -154,7 +156,8 @@ void AArch64TargetInfo::getTargetDefines
   if (Opts.UnsafeFPMath)
     Builder.defineMacro("__ARM_FP_FAST", "1");
 
-  Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", Opts.ShortWChar ? "2" : "4");
+  Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
+                      llvm::utostr(Opts.WCharSize ? Opts.WCharSize : 4));
 
   Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : 
"4");
 
@@ -420,7 +423,6 @@ WindowsARM64TargetInfo::WindowsARM64Targ
 
   // This is an LLP64 platform.
   // int:4, long:4, long long:8, long double:8.
-  WCharType = UnsignedShort;
   IntWidth = IntAlign = 32;
   LongWidth = LongAlign = 32;
   DoubleAlign = LongLongAlign = 64;
@@ -502,7 +504,6 @@ DarwinAArch64TargetInfo::DarwinAArch64Ta
                                                  const TargetOptions &Opts)
     : DarwinTargetInfo<AArch64leTargetInfo>(Triple, Opts) {
   Int64Type = SignedLongLong;
-  WCharType = SignedInt;
   UseSignedCharForObjCBool = false;
 
   LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Fri Oct  6 16:09:55 2017
@@ -36,20 +36,10 @@ void ARMTargetInfo::setABIAAPCS() {
   else
     SizeType = UnsignedInt;
 
-  switch (T.getOS()) {
-  case llvm::Triple::NetBSD:
-  case llvm::Triple::OpenBSD:
-    WCharType = SignedInt;
-    break;
-  case llvm::Triple::Win32:
-    WCharType = UnsignedShort;
-    break;
-  case llvm::Triple::Linux:
-  default:
-    // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int.
+  bool IsNetBSD = T.getOS() == llvm::Triple::NetBSD;
+  bool IsOpenBSD = T.getOS() == llvm::Triple::OpenBSD;
+  if (!T.isOSWindows() && !IsNetBSD && !IsOpenBSD)
     WCharType = UnsignedInt;
-    break;
-  }
 
   UseBitFieldTypeAlignment = true;
 
@@ -99,7 +89,6 @@ void ARMTargetInfo::setABIAPCS(bool IsAA
   else
     SizeType = UnsignedLong;
 
-  // Revert to using SignedInt on apcs-gnu to comply with existing behaviour.
   WCharType = SignedInt;
 
   // Do not respect the alignment of bit-field types when laying out
@@ -689,7 +678,8 @@ void ARMTargetInfo::getTargetDefines(con
                         "0x" + llvm::utohexstr(HW_FP & ~HW_FP_DP));
   }
 
-  Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", Opts.ShortWChar ? "2" : "4");
+  Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
+                      llvm::utostr(Opts.WCharSize ? Opts.WCharSize : 4));
 
   Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : 
"4");
 
@@ -932,7 +922,6 @@ void ARMbeTargetInfo::getTargetDefines(c
 WindowsARMTargetInfo::WindowsARMTargetInfo(const llvm::Triple &Triple,
                                            const TargetOptions &Opts)
     : WindowsTargetInfo<ARMleTargetInfo>(Triple, Opts), Triple(Triple) {
-  WCharType = UnsignedShort;
   SizeType = UnsignedInt;
 }
 
@@ -1023,8 +1012,8 @@ void MinGWARMTargetInfo::getTargetDefine
 CygwinARMTargetInfo::CygwinARMTargetInfo(const llvm::Triple &Triple,
                                          const TargetOptions &Opts)
     : ARMleTargetInfo(Triple, Opts) {
+  this->WCharType = TargetInfo::UnsignedShort;
   TLSSupported = false;
-  WCharType = UnsignedShort;
   DoubleAlign = LongLongAlign = 64;
   resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
 }

Modified: cfe/trunk/lib/Basic/Targets/AVR.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AVR.h?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/AVR.h (original)
+++ cfe/trunk/lib/Basic/Targets/AVR.h Fri Oct  6 16:09:55 2017
@@ -52,7 +52,6 @@ public:
     PtrDiffType = SignedInt;
     IntPtrType = SignedInt;
     Char16Type = UnsignedInt;
-    WCharType = SignedInt;
     WIntType = SignedInt;
     Char32Type = UnsignedLong;
     SigAtomicType = SignedChar;

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Fri Oct  6 16:09:55 2017
@@ -477,7 +477,7 @@ protected:
 public:
   PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
       : OSTargetInfo<Target>(Triple, Opts) {
-    this->WCharType = this->UnsignedShort;
+    this->WCharType = TargetInfo::UnsignedShort;
 
     // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
     this->MaxTLSAlign = 256;
@@ -561,7 +561,6 @@ protected:
 public:
   SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
       : OSTargetInfo<Target>(Triple, Opts) {
-    this->WCharType = this->SignedInt;
     // FIXME: WIntType should be SignedLong
   }
 };
@@ -628,7 +627,9 @@ protected:
 
 public:
   WindowsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
-      : OSTargetInfo<Target>(Triple, Opts) {}
+      : OSTargetInfo<Target>(Triple, Opts) {
+    this->WCharType = TargetInfo::UnsignedShort;
+  }
 };
 
 template <typename Target>

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Fri Oct  6 16:09:55 2017
@@ -639,7 +639,6 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86
 public:
   WindowsX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions 
&Opts)
       : WindowsTargetInfo<X86_32TargetInfo>(Triple, Opts) {
-    WCharType = UnsignedShort;
     DoubleAlign = LongLongAlign = 64;
     bool IsWinCOFF =
         getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
@@ -700,7 +699,7 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_
 public:
   CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
       : X86_32TargetInfo(Triple, Opts) {
-    WCharType = UnsignedShort;
+    this->WCharType = TargetInfo::UnsignedShort;
     DoubleAlign = LongLongAlign = 64;
     resetDataLayout("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32");
   }
@@ -886,7 +885,6 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86
 public:
   WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions 
&Opts)
       : WindowsTargetInfo<X86_64TargetInfo>(Triple, Opts) {
-    WCharType = UnsignedShort;
     LongWidth = LongAlign = 32;
     DoubleAlign = LongLongAlign = 64;
     IntMaxType = SignedLongLong;
@@ -979,8 +977,8 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_
 public:
   CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
       : X86_64TargetInfo(Triple, Opts) {
+    this->WCharType = TargetInfo::UnsignedShort;
     TLSSupported = false;
-    WCharType = UnsignedShort;
   }
 
   void getTargetDefines(const LangOptions &Opts,

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Oct  6 16:09:55 2017
@@ -2601,6 +2601,33 @@ static void RenderModulesOptions(Compila
   Args.AddLastArg(CmdArgs, 
options::OPT_fmodules_disable_diagnostic_validation);
 }
 
+static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T,
+                                   ArgStringList &CmdArgs) {
+  // -fsigned-char is default.
+  if (const Arg *A = Args.getLastArg(options::OPT_fsigned_char,
+                                     options::OPT_fno_signed_char,
+                                     options::OPT_funsigned_char,
+                                     options::OPT_fno_unsigned_char)) {
+    if (A->getOption().matches(options::OPT_funsigned_char) ||
+        A->getOption().matches(options::OPT_fno_signed_char)) {
+      CmdArgs.push_back("-fno-signed-char");
+    }
+  } else if (!isSignedCharDefault(T)) {
+    CmdArgs.push_back("-fno-signed-char");
+  }
+
+  if (const Arg *A = Args.getLastArg(options::OPT_fshort_wchar,
+                                     options::OPT_fno_short_wchar)) {
+    if (A->getOption().matches(options::OPT_fshort_wchar)) {
+      CmdArgs.push_back("-fwchar-type=short");
+      CmdArgs.push_back("-fno-signed-wchar");
+    } else {
+      CmdArgs.push_back("-fwchar-type=int");
+      CmdArgs.push_back("-fsigned-wchar");
+    }
+  }
+}
+
 static void RenderObjCOptions(const ToolChain &TC, const Driver &D,
                               const llvm::Triple &T, const ArgList &Args,
                               ObjCRuntime &Runtime, bool InferCovariantReturns,
@@ -2991,6 +3018,9 @@ void Clang::ConstructJob(Compilation &C,
           Inputs.size() == 1) &&
          "Unable to handle multiple inputs.");
 
+  const llvm::Triple *AuxTriple =
+      IsCuda ? getToolChain().getAuxTriple() : nullptr;
+
   bool IsWindowsGNU = RawTriple.isWindowsGNUEnvironment();
   bool IsWindowsCygnus = RawTriple.isWindowsCygwinEnvironment();
   bool IsWindowsMSVC = RawTriple.isWindowsMSVCEnvironment();
@@ -3000,7 +3030,6 @@ void Clang::ConstructJob(Compilation &C,
   // mode (i.e., getToolchain().getTriple() is NVPTX, not Windows), we need to
   // pass Windows-specific flags to cc1.
   if (IsCuda) {
-    const llvm::Triple *AuxTriple = getToolChain().getAuxTriple();
     IsWindowsMSVC |= AuxTriple && AuxTriple->isWindowsMSVCEnvironment();
     IsWindowsGNU |= AuxTriple && AuxTriple->isWindowsGNUEnvironment();
     IsWindowsCygnus |= AuxTriple && AuxTriple->isWindowsCygwinEnvironment();
@@ -4003,17 +4032,7 @@ void Clang::ConstructJob(Compilation &C,
                    getToolChain().getArch() == llvm::Triple::hexagon))
     CmdArgs.push_back("-fshort-enums");
 
-  // -fsigned-char is default.
-  if (Arg *A = Args.getLastArg(
-          options::OPT_fsigned_char, options::OPT_fno_signed_char,
-          options::OPT_funsigned_char, options::OPT_fno_unsigned_char)) {
-    if (A->getOption().matches(options::OPT_funsigned_char) ||
-        A->getOption().matches(options::OPT_fno_signed_char)) {
-      CmdArgs.push_back("-fno-signed-char");
-    }
-  } else if (!isSignedCharDefault(RawTriple)) {
-    CmdArgs.push_back("-fno-signed-char");
-  }
+  RenderCharacterOptions(Args, AuxTriple ? *AuxTriple : RawTriple, CmdArgs);
 
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
@@ -4182,12 +4201,6 @@ void Clang::ConstructJob(Compilation &C,
                     options::OPT_mno_constant_cfstrings))
     CmdArgs.push_back("-fno-constant-cfstrings");
 
-  // -fshort-wchar default varies depending on platform; only
-  // pass if specified.
-  if (Arg *A = Args.getLastArg(options::OPT_fshort_wchar,
-                               options::OPT_fno_short_wchar))
-    A->render(Args, CmdArgs);
-
   // -fno-pascal-strings is default, only pass non-default.
   if (Args.hasFlag(options::OPT_fpascal_strings,
                    options::OPT_fno_pascal_strings, false))

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Oct  6 16:09:55 2017
@@ -386,6 +386,7 @@ void CompilerInstance::createPreprocesso
       Invocation->getPreprocessorOptsPtr(), getDiagnostics(), getLangOpts(),
       getSourceManager(), getPCMCache(), *HeaderInfo, *this, PTHMgr,
       /*OwnsHeaderSearch=*/true, TUKind);
+  getTarget().adjust(getLangOpts());
   PP->Initialize(getTarget(), getAuxTarget());
 
   // Note that this is different then passing PTHMgr to Preprocessor's ctor.

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Oct  6 16:09:55 2017
@@ -2154,7 +2154,16 @@ static void ParseLangArgs(LangOptions &O
   Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules);
   Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char);
   Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar);
-  Opts.ShortWChar = Args.hasFlag(OPT_fshort_wchar, OPT_fno_short_wchar, false);
+  if (const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) {
+    Opts.WCharSize = llvm::StringSwitch<unsigned>(A->getValue())
+                         .Case("char", 1)
+                         .Case("short", 2)
+                         .Case("int", 4)
+                         .Default(0);
+    if (Opts.WCharSize == 0)
+      Diags.Report(diag::err_fe_invalid_wchar_type) << A->getValue();
+  }
+  Opts.WCharIsSigned = Args.hasFlag(OPT_fsigned_wchar, OPT_fno_signed_wchar, 
true);
   Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
   Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
   Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;

Modified: cfe/trunk/test/CXX/conv/conv.prom/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/conv/conv.prom/p2.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/CXX/conv/conv.prom/p2.cpp (original)
+++ cfe/trunk/test/CXX/conv/conv.prom/p2.cpp Fri Oct  6 16:09:55 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple 
x86_64-pc-linux-gnu -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple 
x86_64-pc-linux-gnu -ffreestanding -fshort-wchar %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple 
x86_64-pc-linux-gnu -ffreestanding -fwchar-type=short -fno-signed-wchar %s
 // expected-no-diagnostics
 
 #include <stdint.h>

Modified: cfe/trunk/test/CodeGen/arm-metadata.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-metadata.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-metadata.c (original)
+++ cfe/trunk/test/CodeGen/arm-metadata.c Fri Oct  6 16:09:55 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s | FileCheck 
-check-prefix=DEFAULT %s
 // RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s 
-fshort-enums | FileCheck -check-prefix=SHORT-ENUM %s
-// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s 
-fshort-wchar | FileCheck -check-prefix=SHORT-WCHAR %s
+// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s 
-fwchar-type=short -fno-signed-wchar | FileCheck -check-prefix=SHORT-WCHAR %s
 
 // DEFAULT:  !{{[0-9]+}} = !{i32 1, !"wchar_size", i32 4}
 // DEFAULT:   !{{[0-9]+}} = !{i32 1, !"min_enum_size", i32 4}

Modified: cfe/trunk/test/CodeGen/pascal-wchar-string.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pascal-wchar-string.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/pascal-wchar-string.c (original)
+++ cfe/trunk/test/CodeGen/pascal-wchar-string.c Fri Oct  6 16:09:55 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o -  %s -fpascal-strings -fshort-wchar  | 
FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o -  %s -fpascal-strings -fwchar-type=short 
-fno-signed-wchar | FileCheck %s
 // rdar://8020384
 
 #include <stddef.h>

Modified: cfe/trunk/test/CodeGen/string-literal-short-wstring.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal-short-wstring.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/string-literal-short-wstring.c (original)
+++ cfe/trunk/test/CodeGen/string-literal-short-wstring.c Fri Oct  6 16:09:55 
2017
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm -fshort-wchar 
%s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
-// RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fshort-wchar %s 
-o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
+// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm 
-fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s 
--check-prefix=CHECK --check-prefix=ITANIUM
+// RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fwchar-type=short 
-fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK 
--check-prefix=MSABI
 // Runs in c++ mode so that wchar_t is available.
 
 // XFAIL: hexagon

Modified: cfe/trunk/test/CodeGen/string-literal-unicode-conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal-unicode-conversion.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/string-literal-unicode-conversion.c (original)
+++ cfe/trunk/test/CodeGen/string-literal-unicode-conversion.c Fri Oct  6 
16:09:55 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-C %s
 // RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm 
%s -o - | FileCheck -check-prefix=CHECK-CPP0X %s
-// RUN: %clang_cc1 -x c++ -std=c++0x -fshort-wchar -triple 
i386-unknown-unknown -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-SHORTWCHAR %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -fwchar-type=short -fno-signed-wchar 
-triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck 
-check-prefix=CHECK-SHORTWCHAR %s
 
 // This file contains a mix of ISO-8859-1 and UTF-8 encoded data.
 // the literal assigned to 'aa' should be the ISO-8859-1 encoding for the code

Modified: cfe/trunk/test/CodeGen/wchar-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wchar-size.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/wchar-size.c (original)
+++ cfe/trunk/test/CodeGen/wchar-size.c Fri Oct  6 16:09:55 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=LONG-WCHAR
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | 
FileCheck %s -check-prefix=SHORT-WCHAR
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fshort-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - 
-fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR
 // Note: -fno-short-wchar implies the target default is used; so there is no
 // need to test this separately here.
 

Modified: cfe/trunk/test/Driver/clang_f_opts.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang_f_opts.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Driver/clang_f_opts.c (original)
+++ cfe/trunk/test/Driver/clang_f_opts.c Fri Oct  6 16:09:55 2017
@@ -1,7 +1,7 @@
 // REQUIRES: clang-driver
 
 // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon 
-fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common 
-fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings 
-fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon 
-fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common 
-fno-pascal-strings -fno-show-source-location -fshort-enums -fshort-wchar %s 
2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon 
-fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common 
-fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck 
-check-prefix=CHECK-OPTIONS2 %s
 
 // CHECK-OPTIONS1: -split-stacks
 // CHECK-OPTIONS1: -fgnu-keywords
@@ -12,7 +12,6 @@
 // CHECK-OPTIONS2: -fno-gnu-keywords
 // CHECK-OPTIONS2: -fno-builtin
 // CHECK-OPTIONS2: -fshort-enums
-// CHECK-OPTIONS2: -fshort-wchar
 // CHECK-OPTIONS2: -fno-common
 // CHECK-OPTIONS2: -fno-show-source-location
 
@@ -466,15 +465,15 @@
 // RUN: %clang -### -S -fno-unsigned-char %s 2>&1 | FileCheck 
-check-prefix=CHAR-SIGN4 %s
 // CHAR-SIGN4-NOT: -fno-signed-char
 
-// RUN: %clang -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck 
-check-prefix=CHECK-WCHAR1 -check-prefix=DELIMITERS %s
-// RUN: %clang -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck 
-check-prefix=CHECK-WCHAR2 -check-prefix=DELIMITERS %s
+// RUN: %clang -target x86_64-unknown-none-none -### -fshort-wchar 
-fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 
-check-prefix=DELIMITERS %s
+// RUN: %clang -target x86_64-unknown-none-none -### -fno-short-wchar 
-fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 
-check-prefix=DELIMITERS %s
 // Make sure we don't match the -NOT lines with the linker invocation.
 // Delimiters match the start of the cc1 and the start of the linker lines
 // DELIMITERS: {{^ *"}}
-// CHECK-WCHAR1: -fno-short-wchar
-// CHECK-WCHAR1-NOT: -fshort-wchar
-// CHECK-WCHAR2: -fshort-wchar
-// CHECK-WCHAR2-NOT: -fno-short-wchar
+// CHECK-WCHAR1: -fwchar-type=int
+// CHECK-WCHAR1-NOT: -fwchar-type=short
+// CHECK-WCHAR2: -fwchar-type=short
+// CHECK-WCHAR2-NOT: -fwchar-type=int
 // DELIMITERS: {{^ *"}}
 
 // RUN: %clang -### -fno-experimental-new-pass-manager 
-fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM 
--check-prefix=CHECK-NEW-PM %s
@@ -499,3 +498,8 @@
 // RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s
 // CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders
 // CHECK-NO-ALLOW-PLACEHOLDERS-NOT: -fallow-editor-placeholders
+
+// RUN: %clang -### -target x86_64-unknown-windows-msvc -fno-short-wchar %s 
2>&1 | FileCheck -check-prefix CHECK-WINDOWS-ISO10646 %s
+// CHECK-WINDOWS-ISO10646: "-fwchar-type=int"
+// CHECK-WINDOWS-ISO10646: "-fsigned-wchar"
+

Modified: cfe/trunk/test/Headers/wchar_limits.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/wchar_limits.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Headers/wchar_limits.cpp (original)
+++ cfe/trunk/test/Headers/wchar_limits.cpp Fri Oct  6 16:09:55 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify %s
-// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -fshort-wchar %s
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -fwchar-type=short 
-fno-signed-wchar %s
 // expected-no-diagnostics
 
 #include <stdint.h>

Modified: cfe/trunk/test/Index/index-pch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-pch.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-pch.cpp (original)
+++ cfe/trunk/test/Index/index-pch.cpp Fri Oct  6 16:09:55 2017
@@ -1,4 +1,4 @@
-// RUN: c-index-test -write-pch %t.pch -fshort-wchar %s
+// RUN: c-index-test -write-pch %t.pch -fwchar-type=short -fno-signed-wchar %s
 // RUN: env LIBCLANG_NOTHREADS=1 c-index-test -index-tu %t.pch | FileCheck %s
 
 // CHECK: [indexDeclaration]: kind: variable | name: wideStr

Modified: cfe/trunk/test/Lexer/wchar.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/wchar.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/wchar.c (original)
+++ cfe/trunk/test/Lexer/wchar.c Fri Oct  6 16:09:55 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fshort-wchar -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fwchar-type=short -fno-signed-wchar -verify 
%s
 
 void f() {
   (void)L"\U00010000"; // unicode escape produces UTF-16 sequence, so no 
warning

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Fri Oct  6 16:09:55 2017
@@ -253,18 +253,18 @@
 // SCHAR-NOT:#define __UNSIGNED_CHAR__
 // SCHAR:#define __clang__ 1
 //
-// RUN: %clang_cc1 -E -dM -fshort-wchar < /dev/null | FileCheck 
-match-full-lines -check-prefix SHORTWCHAR %s
+// RUN: %clang_cc1 -E -dM -fwchar-type=short -fno-signed-wchar < /dev/null | 
FileCheck -match-full-lines -check-prefix SHORTWCHAR %s
 // wchar_t is u16 for targeting Win32.
-// FIXME: Implement and check x86_64-cygwin.
-// RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=x86_64-w64-mingw32 < 
/dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s
+// RUN: %clang_cc1 -E -dM -fwchar-type=short -fno-signed-wchar 
-triple=x86_64-w64-mingw32 < /dev/null | FileCheck -match-full-lines 
-check-prefix SHORTWCHAR %s
+// RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar 
-triple=x86_64-unknown-windows-cygnus -E /dev/null | FileCheck 
-match-full-lines -check-prefix SHORTWCHAR %s
 //
 // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2
 // SHORTWCHAR: #define __WCHAR_MAX__ 65535
 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
 // SHORTWCHAR: #define __WCHAR_WIDTH__ 16
 //
-// RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=i686-unknown-unknown < 
/dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
-// RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=x86_64-unknown-unknown < 
/dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
+// RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=i686-unknown-unknown < 
/dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
+// RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=x86_64-unknown-unknown < 
/dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
 //
 // SHORTWCHAR2: #define __SIZEOF_WCHAR_T__ 4
 // SHORTWCHAR2: #define __WCHAR_WIDTH__ 32

Modified: cfe/trunk/test/Preprocessor/pr19649-unsigned-wchar_t.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pr19649-unsigned-wchar_t.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pr19649-unsigned-wchar_t.c (original)
+++ cfe/trunk/test/Preprocessor/pr19649-unsigned-wchar_t.c Fri Oct  6 16:09:55 
2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-pc-cygwin -E -x c %s
-// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -fshort-wchar -x c %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -fwchar-type=short 
-fno-signed-wchar -x c %s
 
 #if (L'\0' - 1 < 0)
 # error "Unexpected expression evaluation result"

Added: cfe/trunk/test/Preprocessor/wchar_t.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/wchar_t.c?rev=315126&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/wchar_t.c (added)
+++ cfe/trunk/test/Preprocessor/wchar_t.c Fri Oct  6 16:09:55 2017
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -triple i386-pc-solaris -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-SOLARIS
+// CHECK-SOLARIS-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-SOLARIS-DAG: #define __WCHAR_TYPE__ int
+// CHECK-SOLARIS-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple avr-unknown-unknown -fwchar-type=int -fsigned-wchar 
-dM -E %s -o - | FileCheck %s -check-prefix CHECK-AVR
+// CHECK-AVR-DAG: #define __WCHAR_MAX__ 32767
+// CHECK-AVR-DAG: #define __WCHAR_TYPE__ int
+// CHECK-AVR-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple arm-unknown-none-gnu -fsigned-wchar -dM -E %s -o - 
| FileCheck %s -check-prefix CHECK-ARM-APCS
+// CHECK-ARM-APCS-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-ARM-APCS-DAG: #define __WCHAR_TYPE__ int
+// CHECK-ARM-APCS-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple arm-unknown-netbsd-gnu -fsigned-wchar -dM -E %s -o 
- | FileCheck %s -check-prefix CHECK-ARM-NETBSD-AAPCS
+// CHECK-ARM-NETBSD-AAPCS-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-ARM-NETBSD-AAPCS-DAG: #define __WCHAR_TYPE__ int
+// CHECK-ARM-NETBSD-AAPCS-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple arm-unknown-openbsd -fsigned-wchar -dM -E %s -o - | 
FileCheck %s -check-prefix CHECK-ARM-OPENBSD
+// CHECK-ARM-OPENBSD-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-ARM-OPENBSD-DAG: #define __WCHAR_TYPE__ int
+// CHECK-ARM-OPENBSD-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsigned-wchar -dM -E %s -o - | 
FileCheck %s -check-prefix CHECK-ARM64-DARWIN
+// CHECK-ARM64-DARWIN-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-ARM64-DARWIN-DAG: #define __WCHAR_TYPE__ int
+// CHECK-ARM64-DARWIN-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple aarch64-unknown-netbsd -fsigned-wchar -dM -E %s -o 
- | FileCheck %s -check-prefix CHECK-ARM64-NETBSD
+// CHECK-ARM64-NETBSD-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-ARM64-NETBSD-DAG: #define __WCHAR_TYPE__ int
+// CHECK-ARM64-NETBSD-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple aarch64-unknown-openbsd -fsigned-wchar -dM -E %s -o 
- | FileCheck %s -check-prefix CHECK-ARM64-OPENBSD
+// CHECK-ARM64-OPENBSD-DAG: #define __WCHAR_MAX__ 2147483647
+// CHECK-ARM64-OPENBSD-DAG: #define __WCHAR_TYPE__ int
+// CHECK-ARM64-OPENBSD-NOT: #define __WCHAR_UNSIGNED__ 0
+
+// RUN: %clang_cc1 -triple aarch64-unknown-none -fwchar-type=int 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix 
CHECK-ARM64-AAPCS64
+// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_MAX__ 4294967295U
+// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int
+// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE
+// CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255
+// CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char
+// CHECK-XCORE-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-cygnus -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-X64
+// CHECK-CYGWIN-X64-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-CYGWIN-X64-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-CYGWIN-X64-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-X64
+// CHECK-MSVC-X64-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-MSVC-X64-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-MSVC-X64-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple i686-unknown-windows-cygnus -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-X86
+// CHECK-CYGWIN-X86-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-CYGWIN-X86-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-CYGWIN-X86-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-X86
+// CHECK-MSVC-X86-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-MSVC-X86-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-MSVC-X86-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-PS4
+// CHECK-PS4-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-PS4-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-PS4-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-cygnus -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-ARM
+// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-ARM
+// CHECK-MSVC-ARM-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-MSVC-ARM-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-MSVC-ARM-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fwchar-type=short 
-fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-ARM64
+// CHECK-MSVC-ARM64-DAG: #define __WCHAR_MAX__ 65535
+// CHECK-MSVC-ARM64-DAG: #define __WCHAR_TYPE__ unsigned short
+// CHECK-MSVC-ARM64-DAG: #define __WCHAR_UNSIGNED__ 1
+
+// RUN: %clang_cc1 -triple i386-apple-macosx -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple ppc64-apple-macosx -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple i386-apple-ios -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple x86_64-apple-ios -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple armv7-apple-ios -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple aarch64-apple-ios -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple i386-apple-tvos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple x86_64-apple-tvos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple armv7-apple-tvos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple aarch64-apple-tvos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple i386-apple-watchos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple x86_64-apple-watchos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple armv7-apple-watchos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// RUN: %clang_cc1 -triple aarch64-apple-watchos -dM -E %s -o - | FileCheck %s 
-check-prefix CHECK-DARWIN
+// CHECK-DARWIN: #define __WCHAR_TYPE__ int
+
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fwchar-type=int 
-fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix 
CHECK-WINDOWS-ISO10646
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fwchar-type=int 
-fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix 
CHECK-WINDOWS-ISO10646
+// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fwchar-type=int 
-fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix 
CHECK-WINDOWS-ISO10646
+// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fwchar-type=int 
-fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix 
CHECK-WINDOWS-ISO10646
+// CHECK-WINDOWS-ISO10646: #define __WCHAR_TYPE__ int
+

Modified: cfe/trunk/test/Sema/wchar.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/wchar.c?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/Sema/wchar.c (original)
+++ cfe/trunk/test/Sema/wchar.c Fri Oct  6 16:09:55 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
-// RUN: %clang_cc1 %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR
+// RUN: %clang_cc1 %s -fsyntax-only -fwchar-type=short -fno-signed-wchar 
-verify -DSHORT_WCHAR
 
 typedef __WCHAR_TYPE__ wchar_t;
 

Modified: cfe/trunk/test/SemaCXX/short-wchar-sign.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/short-wchar-sign.cpp?rev=315126&r1=315125&r2=315126&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/short-wchar-sign.cpp (original)
+++ cfe/trunk/test/SemaCXX/short-wchar-sign.cpp Fri Oct  6 16:09:55 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -pedantic -verify %s
-// RUN: %clang_cc1 -fshort-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only 
-pedantic -verify %s
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic 
-verify %s
 // expected-no-diagnostics
 


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to