[PATCH] clang-cl: Add the /c, /W0 and /W1 options

Hans Wennborg hans at chromium.org
Tue Jul 30 15:54:28 PDT 2013


  So, this was a pretty bad example of options that would require manual translation as it turned out they could both be alises (to -w and -Wall).

  I looked at the coding in Tooling.cpp where we build up the CC1 command line argument list, and there it seems pretty scary, so I hope we can avoid adding too much code there.

  One thing I plan on doing is expand the alias mechanism of the option parser. For example, we currently translate -ansi to -std=c89 manually in Tools.cpp. Since -std= is a joined option, we can't do this in tablegen directly. I'm working on a patch to make that possible, and with that I think we can make 99% of the clang-cl options be tablegen defined aliases.


================
Comment at: include/clang/Driver/Options.td:176
@@ -173,3 +175,3 @@
 
-def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption]>,
+def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CLOption]>,
     HelpText<"Print the commands to run for this compilation">;
----------------
Reid Kleckner wrote:
> Probably worth a TODO that in the long run this should be ClangOption instead of CLOption.
Will do.

================
Comment at: include/clang/Driver/CLCompatOptions.td:24
@@ +23,3 @@
+  HelpText<"Display available options">;
+def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">;
+def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias<Wall>;
----------------
Chandler Carruth wrote:
> shouldn't this be an alias for '-w'?
Ah, didn't know about that one. Yes, -w will work nicely.

================
Comment at: lib/Driver/WindowsToolChain.cpp:351
@@ +350,3 @@
+      break;
+    case options::OPT__SLASH_W1:
+      Alias = "all";
----------------
Chandler Carruth wrote:
> Reid Kleckner wrote:
> > Is it necessary to have this custom handling for aliased options?  I was hoping to limit the custom handling to things that can't be expressed as simple aliases like -W0.
> I don't understand why all of these can't be handled with aliases, and no hand authored C++ code.
I didn't realize it when I wrote thepatch, but both /W0 and /W1 can be aliases to -w and -Wall (which is a real Option), respectively.


http://llvm-reviews.chandlerc.com/D1232



More information about the cfe-commits mailing list