]> granicus.if.org Git - clang/commitdiff
clang-cl: Accept MSVC 2015's `/execution-charset:utf-8` flag.
authorNico Weber <nicolasweber@gmx.de>
Fri, 26 Aug 2016 21:11:43 +0000 (21:11 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 26 Aug 2016 21:11:43 +0000 (21:11 +0000)
Also makes -fexec-charset accept utf-8 case-insensitively.
Like https://reviews.llvm.org/D23807, but for execution-charset.
Also replace a few .lower() comparisons with equals_lower().

https://reviews.llvm.org/D23938

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279866 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CLCompatOptions.td
lib/Driver/Tools.cpp
test/Driver/cl-options.c

index ec2646d712cfd3467093cc438f044b232655d87c..2728829a05ccd608968c0e66ab5aefcc7d0b63c6 100644 (file)
@@ -122,6 +122,8 @@ def _SLASH_showIncludes : CLFlag<"showIncludes">,
   Alias<show_includes>;
 def _SLASH_source_charset : CLCompileJoined<"source-charset:">,
   HelpText<"Source encoding, supports only UTF-8">, Alias<finput_charset_EQ>;
+def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">,
+  HelpText<"Runtime encoding, supports only UTF-8">, Alias<fexec_charset_EQ>;
 def _SLASH_std : CLCompileJoined<"std:">,
   HelpText<"Language standard to compile for">;
 def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
index 18b22bc2c9f6aaf4423d3492d0d4cdd8f92fb092..5852ac1b2e2610133b98e882e31c606b66566098 100644 (file)
@@ -5835,7 +5835,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // -finput_charset=UTF-8 is default. Reject others
   if (Arg *inputCharset = Args.getLastArg(options::OPT_finput_charset_EQ)) {
     StringRef value = inputCharset->getValue();
-    if (value.lower() != "utf-8")
+    if (!value.equals_lower("utf-8"))
       D.Diag(diag::err_drv_invalid_value) << inputCharset->getAsString(Args)
                                           << value;
   }
@@ -5843,7 +5843,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // -fexec_charset=UTF-8 is default. Reject others
   if (Arg *execCharset = Args.getLastArg(options::OPT_fexec_charset_EQ)) {
     StringRef value = execCharset->getValue();
-    if (value != "UTF-8")
+    if (!value.equals_lower("utf-8"))
       D.Diag(diag::err_drv_invalid_value) << execCharset->getAsString(Args)
                                           << value;
   }
@@ -9219,7 +9219,7 @@ void gnutools::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
     // march from being picked in the absence of a cpu flag.
     Arg *A;
     if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-        StringRef(A->getValue()).lower() == "krait")
+        StringRef(A->getValue()).equals_lower("krait"))
       CmdArgs.push_back("-mcpu=cortex-a15");
     else
       Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
index 5f7849ab7df5cf4709571d0bbc467ea1be518380..52b40c716daed1eafb5f8ae1ee190f4ae3affe60 100644 (file)
 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
 // source-charset-utf-16: invalid value 'utf-16'
 
+// /execution-charset: should warn on everything except UTF-8.
+// RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
+// execution-charset-utf-16: invalid value 'utf-16'
+//
 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
 // RUN:    /d2FastFail \
 // RUN:    /d2Zi+ \
 // RUN:    /errorReport:foo \
+// RUN:    /execution-charset:utf-8 \
 // RUN:    /FC \
 // RUN:    /Fdfoo \
 // RUN:    /FS \