r224791 - clang-cl: Various changes to /Zc: handling.

Nico Weber nicolasweber at gmx.de
Tue Dec 23 14:55:34 PST 2014


Author: nico
Date: Tue Dec 23 16:55:34 2014
New Revision: 224791

URL: http://llvm.org/viewvc/llvm-project?rev=224791&view=rev
Log:
clang-cl: Various changes to /Zc: handling.

* /Zc:trigraphs and /Zc:trigraphs- are now honored
* /Zc:strictStrings is now honored
* /Zc:auto is now honored/ignored (clang does the Right Thing for this already)

Also add a dedicated test for the various /Zc: flags.
clang-cl doesn't always agree with cl.exe on the default values for /Zc flags.
For example, I think clang always behaves as if /Zc:inline is passed, and
warns if the user explicitly passes /Zc:inline-

Fixes PR21974.

Added:
    cfe/trunk/test/Driver/cl-zc.cpp
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=224791&r1=224790&r2=224791&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Dec 23 16:55:34 2014
@@ -129,6 +129,13 @@ def _SLASH_wd4005 : CLFlag<"wd4005">, Al
   AliasArgs<["no-macro-redefined"]>;
 def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">,
   Alias<vtordisp_mode_EQ>;
+def _SLASH_Zc_strictStrings : CLFlag<"Zc:strictStrings">,
+  HelpText<"Treat string literals as const">, Alias<W_Joined>,
+  AliasArgs<["error=c++11-compat-deprecated-writable-strings"]>;
+def _SLASH_Zc_trigraphs : CLFlag<"Zc:trigraphs">,
+  HelpText<"Enable trigraphs">, Alias<ftrigraphs>;
+def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">,
+  HelpText<"Disable trigraphs (default)">, Alias<fno_trigraphs>;
 def _SLASH_Z7 : CLFlag<"Z7">, Alias<gline_tables_only>;
 def _SLASH_Zi : CLFlag<"Zi">, HelpText<"Enable debug information">,
   Alias<gline_tables_only>;
@@ -213,6 +220,7 @@ def _SLASH_sdl : CLIgnoredFlag<"sdl">;
 def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">;
 def _SLASH_volatile_iso : CLIgnoredFlag<"volatile:iso">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
 def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">;
 def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=224791&r1=224790&r2=224791&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Dec 23 16:55:34 2014
@@ -191,10 +191,6 @@
 // RUN:    /volatile:iso \
 // RUN:    /w12345 \
 // RUN:    /wd1234 \
-// RUN:    /Zc:forScope \
-// RUN:    /Zc:wchar_t \
-// RUN:    /Zc:inline \
-// RUN:    /Zc:rvalueCast \
 // RUN:    /Zo \
 // RUN:    /Zo- \
 // RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
@@ -285,8 +281,6 @@
 // RUN:     /Yustdafx.h \
 // RUN:     /Z7 \
 // RUN:     /Za \
-// RUN:     /Zc:auto \
-// RUN:     /Zc:wchar_t- \
 // RUN:     /Ze \
 // RUN:     /Zg \
 // RUN:     /Zi \

Added: cfe/trunk/test/Driver/cl-zc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-zc.cpp?rev=224791&view=auto
==============================================================================
--- cfe/trunk/test/Driver/cl-zc.cpp (added)
+++ cfe/trunk/test/Driver/cl-zc.cpp Tue Dec 23 16:55:34 2014
@@ -0,0 +1,59 @@
+// Don't attempt slash switches on msys bash.
+// REQUIRES: shell-preserves-root
+
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-DEFAULT %s
+// cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
+// isn't explicitly passed.
+// TRIGRAPHS-DEFAULT-NOT: "-ftrigraphs"
+
+// RUN: %clang_cl /c -### /Zc:trigraphs -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-ON %s
+// TRIGRAPHS-ON: "-ftrigraphs"
+
+// RUN: %clang_cl /c -### /Zc:trigraphs- -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-OFF %s
+// TRIGRAPHS-OFF: "-fno-trigraphs"
+
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-DEFAULT %s
+// STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
+// RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-ON %s
+// STRICTSTRINGS-ON: -Werror=c++11-compat-deprecated-writable-strings
+// RUN: %clang_cl /c -### /Zc:strictStrings- -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-OFF %s
+// STRICTSTRINGS-OFF: argument unused during compilation
+
+
+// RUN: %clang_cl /c -### /Zc:foobar -- %s 2>&1 | FileCheck -check-prefix=FOOBAR-ON %s
+// FOOBAR-ON: argument unused during compilation
+// RUN: %clang_cl /c -### /Zc:foobar- -- %s 2>&1 | FileCheck -check-prefix=FOOBAR-ON %s
+// FOOBAR-OFF: argument unused during compilation
+
+// These are ignored if enabled, and warn if disabled.
+
+// RUN: %clang_cl /c -### /Zc:forScope -- %s 2>&1 | FileCheck -check-prefix=FORSCOPE-ON %s
+// FORSCOPE-ON-NOT: argument unused during compilation
+// RUN: %clang_cl /c -### /Zc:forScope- -- %s 2>&1 | FileCheck -check-prefix=FORSCOPE-OFF %s
+// FORSCOPE-OFF: argument unused during compilation
+
+// RUN: %clang_cl /c -### /Zc:wchar_t -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-ON %s
+// WCHAR_T-ON-NOT: argument unused during compilation
+// RUN: %clang_cl /c -### /Zc:wchar_t- -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-OFF %s
+// WCHAR_T-OFF: argument unused during compilation
+
+// RUN: %clang_cl /c -### /Zc:auto -- %s 2>&1 | FileCheck -check-prefix=AUTO-ON %s
+// AUTO-ON-NOT: argument unused during compilation
+// RUN: %clang_cl /c -### /Zc:auto- -- %s 2>&1 | FileCheck -check-prefix=AUTO-OFF %s
+// AUTO-OFF: argument unused during compilation
+
+// RUN: %clang_cl /c -### /Zc:inline -- %s 2>&1 | FileCheck -check-prefix=INLINE-ON %s
+// INLINE-ON-NOT: argument unused during compilation
+// RUN: %clang_cl /c -### /Zc:inline- -- %s 2>&1 | FileCheck -check-prefix=INLINE-OFF %s
+// INLINE-OFF: argument unused during compilation
+
+
+// These never warn, but don't have an effect yet.
+
+// RUN: %clang_cl /c -### /Zc:rvalueCast -- %s 2>&1 | FileCheck -check-prefix=RVALUECAST-ON %s
+// RVALUECAST-ON-NOT: argument unused during compilation
+// RUN: %clang_cl /c -### /Zc:rvalueCast- -- %s 2>&1 | FileCheck -check-prefix=RVALUECAST-OFF %s
+// RVALUECAST-OFF: argument unused during compilation





More information about the cfe-commits mailing list