Author: nico
Date: Fri Aug 26 16:51:14 2016
New Revision: 279872

URL: http://llvm.org/viewvc/llvm-project?rev=279872&view=rev
Log:
clang-cl: Support MSVC2015's /validate-charset flag.

Clang always assumes that files are utf-8. If an invalidly encoded character is
used in an identifier, clang always errors. If it's used in a character
literal, clang warns Winvalid-source-encoding (on by default). Clang never
checks the encoding of things in comments (adding this seems like a nice
feature if it doesn't impact performance).

For cl.exe /utf-8 (which enables /validate-charset), if a bad character is used
in an identifier, it emits both an error and a warning. If it's used in a
literal or a comment, it emits a warning.

So mapping /validate-charset to -Winvalid-source-encoding seems like a fairly
decent fit.

https://reviews.llvm.org/D23945

Modified:
    cfe/trunk/include/clang/Driver/CLCompatOptions.td
    cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=279872&r1=279871&r2=279872&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Aug 26 16:51:14 2016
@@ -128,6 +128,10 @@ def _SLASH_std : CLCompileJoined<"std:">
   HelpText<"Language standard to compile for">;
 def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
   MetaVarName<"<macro>">, Alias<U>;
+def _SLASH_validate_charset : CLFlag<"validate-charset">,
+  Alias<W_Joined>, AliasArgs<["invalid-source-encoding"]>;
+def _SLASH_validate_charset_ : CLFlag<"validate-charset-">,
+  Alias<W_Joined>, AliasArgs<["no-invalid-source-encoding"]>;
 def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias<w>;
 def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias<Wall>;
 def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias<Wall>;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=279872&r1=279871&r2=279872&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Aug 26 16:51:14 2016
@@ -192,6 +192,12 @@
 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
 // U: "-U" "mymacro"
 
+// RUN: %clang_cl /validate-charset -### -- %s 2>&1 | FileCheck 
-check-prefix=validate-charset %s
+// validate-charset: -Winvalid-source-encoding
+
+// RUN: %clang_cl /validate-charset- -### -- %s 2>&1 | FileCheck 
-check-prefix=validate-charset_ %s
+// validate-charset_: -Wno-invalid-source-encoding
+
 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
 // VD2: -vtordisp-mode=2
 


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

Reply via email to