This is an archive of the discontinued LLVM Phabricator instance.

clang-cl: Warn about /U flags that look like filenames (PR31662)
ClosedPublic

Authored by hans on Jan 26 2017, 1:50 PM.

Details

Summary

Both on Mac and Windows, it's common to have a 'Users' directory in the root of the filesystem, so one might specify a filename as '/Users/me/myfile.c'. clang-cl (as well as MSVC's cl.exe) will interpret that as invoking '/U' option, which is probably not what the user wanted. Add a warning about this.

Diff Detail

Repository
rL LLVM

Event Timeline

hans created this revision.Jan 26 2017, 1:50 PM
amccarth added inline comments.
include/clang/Basic/DiagnosticDriverKinds.td
252 ↗(On Diff #85963)

For Windows, wouldn't it make more sense to suggest using valid paths (with backslashes instead of slashes)?

What about all the other characters paths can begin with? Shouldn't we also warn that /code/myproject will also be interpreted as /c rather than \code\myproject?

hans added inline comments.Jan 26 2017, 2:59 PM
include/clang/Basic/DiagnosticDriverKinds.td
252 ↗(On Diff #85963)

I think it's better with a suggestion that works on both platforms.

I also think users run into this more often on non-Windows.

For /code/myproject we will not interpret it as the /c option since it has to be an exact match. /I, /D and others are problematic though.

I think it's hard to fix this in general, but /U is the one people keep running into, so I think targeting that with a warning makes sense.

rnk accepted this revision.Jan 26 2017, 3:47 PM

lgtm

This revision is now accepted and ready to land.Jan 26 2017, 3:47 PM
compnerd accepted this revision.Jan 26 2017, 6:24 PM

Thanks for adding this, diagnosing what was going on here the first time around took a little bit of thinking.

This revision was automatically updated to reflect the committed changes.