This is an archive of the discontinued LLVM Phabricator instance.

clang-cl Add support for two MSVC conversion warnings
AbandonedPublic

Authored by ehsan on Oct 30 2014, 2:42 PM.

Details

Reviewers
hansw

Diff Detail

Event Timeline

ehsan updated this revision to Diff 15583.Oct 30 2014, 2:42 PM
ehsan retitled this revision from to clang-cl Add support for two MSVC conversion warnings.
ehsan updated this object.
ehsan edited the test plan for this revision. (Show Details)
ehsan added a reviewer: hansw.
ehsan added a subscriber: Unknown Object (MLST).
rnk added a subscriber: rnk.Oct 30 2014, 3:05 PM

It doesn't look like there's a really clean mapping for these warnings from MSVC to clang. I don't want to have overly broad mappings from cl warnings to clang warnings because hopefully clang's on-by-default warnings have lower false positive rates.

If you're actually investigating cleaning up clang warnings, I recommend using the gcc style -W / -Wno flags that we expose through clang-cl. These are much finer grained.

include/clang/Driver/CLCompatOptions.td
131

Doesn't this also cover integer conversion? The MSDN article makes it appear that way:
http://msdn.microsoft.com/en-us/library/th7a07tz.aspx

We could make this -Wno-conversion, but that's a pretty big hammer.

test/Driver/cl-options.c
167–175

I'd combine this to speed up the test a bit.

In D6041#4, @rnk wrote:

It doesn't look like there's a really clean mapping for these warnings from MSVC to clang. I don't want to have overly broad mappings from cl warnings to clang warnings because hopefully clang's on-by-default warnings have lower false positive rates.

If you're actually investigating cleaning up clang warnings, I recommend using the gcc style -W / -Wno flags that we expose through clang-cl. These are much finer grained.

These are two MSVC warnings that we disable for Firefox. That's why I'm implementing them in clang-cl.

include/clang/Driver/CLCompatOptions.td
131

Originally I mapped this to Wno-int-conversion too, but it seems like the support for passing more than one string to ArgList is broken (in that I was getting -Wno-float-conversion no-int-conversion passed to cc1). After applying this local LLVM patch, things worked correctly, but I'm not sure if this patch is correct or not (it doesn't break any tests, it seems.)

diff --git a/lib/Option/Arg.cpp b/lib/Option/Arg.cpp
index 4c8da58..c6120d8 100644
--- a/lib/Option/Arg.cpp
+++ b/lib/Option/Arg.cpp
@@ -107,10 +107,9 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const {
   }

  case Option::RenderJoinedStyle:
-    Output.push_back(Args.GetOrMakeJoinedArgString(
-                       getIndex(), getSpelling(), getValue(0)));
     for (unsigned i = 1, e = getNumValues(); i != e; ++i)
-      Output.push_back(getValue(i));
+      Output.push_back(Args.GetOrMakeJoinedArgString(
+                         getIndex(), getSpelling(), getValue(i)));
     break;

   case Option::RenderSeparateStyle:
hans added a subscriber: hans.Oct 31 2014, 8:10 AM

Do we really want to try supporting the individual MSVC warning flags?

It will never be a clean mapping anyway, and the diagnostics won't be very nice. For example, Clang won't print the MSVC style warning names when issuing a warning.

Can't you just use the same list of enabled/disabled warning that you use with Clang on other platforms?

In D6041#7, @hans wrote:

Do we really want to try supporting the individual MSVC warning flags?

It will never be a clean mapping anyway, and the diagnostics won't be very nice. For example, Clang won't print the MSVC style warning names when issuing a warning.

Can't you just use the same list of enabled/disabled warning that you use with Clang on other platforms?

Yeah, I suppose we could do that... Should we can this patch, then?

hans added a comment.Oct 31 2014, 8:21 AM
In D6041#9, @ehsan wrote:
In D6041#7, @hans wrote:

Do we really want to try supporting the individual MSVC warning flags?

It will never be a clean mapping anyway, and the diagnostics won't be very nice. For example, Clang won't print the MSVC style warning names when issuing a warning.

Can't you just use the same list of enabled/disabled warning that you use with Clang on other platforms?

Yeah, I suppose we could do that... Should we can this patch, then?

I'd be in favor of that.

I think we should certainly support the broad flags, like turning all warnings off, treating them as errors, etc. But for controlling individual Clang warnings, I think it makes sense to use Clang flags.

ehsan abandoned this revision.Oct 31 2014, 8:23 AM

OK, makes sense.