From: Nico Weber Date: Fri, 26 Aug 2016 21:11:43 +0000 (+0000) Subject: clang-cl: Accept MSVC 2015's `/execution-charset:utf-8` flag. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=361bfc14a06347a3e4c3b389e6e625c6aacdd876;p=clang clang-cl: Accept MSVC 2015's `/execution-charset:utf-8` flag. 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 --- diff --git a/include/clang/Driver/CLCompatOptions.td b/include/clang/Driver/CLCompatOptions.td index ec2646d712..2728829a05 100644 --- a/include/clang/Driver/CLCompatOptions.td +++ b/include/clang/Driver/CLCompatOptions.td @@ -122,6 +122,8 @@ def _SLASH_showIncludes : CLFlag<"showIncludes">, Alias; def _SLASH_source_charset : CLCompileJoined<"source-charset:">, HelpText<"Source encoding, supports only UTF-8">, Alias; +def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, + HelpText<"Runtime encoding, supports only UTF-8">, Alias; def _SLASH_std : CLCompileJoined<"std:">, HelpText<"Language standard to compile for">; def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 18b22bc2c9..5852ac1b2e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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); diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c index 5f7849ab7d..52b40c716d 100644 --- a/test/Driver/cl-options.c +++ b/test/Driver/cl-options.c @@ -184,6 +184,10 @@ // 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" @@ -289,6 +293,7 @@ // RUN: /d2FastFail \ // RUN: /d2Zi+ \ // RUN: /errorReport:foo \ +// RUN: /execution-charset:utf-8 \ // RUN: /FC \ // RUN: /Fdfoo \ // RUN: /FS \