Commit Graph

144 Commits

Author SHA1 Message Date
Hans Wennborg 883522b1fa clang-cl: Alias /d1reportAllClassLayout to -fdump-record-layouts (PR32826)
llvm-svn: 301567
2017-04-27 17:19:07 +00:00
Hans Wennborg 21793a617a clang-cl: Support the /Zc:twoPhase[-] command-line option (PR32680)
It sounds like MSVC is adding support for two-phase name lookup in a
future version, enabled by this flag (see bug).

Differential Revision: https://reviews.llvm.org/D32138

llvm-svn: 300501
2017-04-17 21:28:36 +00:00
Bob Haarman aaf5191364 enable -flto=thin in clang-cl
Summary: This enables LTO to be used with the clang-cl frontend.

Reviewers: rnk, hans

Reviewed By: hans

Subscribers: pcc, cfe-commits, mehdi_amini, Prazek

Differential Revision: https://reviews.llvm.org/D30239

llvm-svn: 296373
2017-02-27 19:40:19 +00:00
Hans Wennborg 091f1b6ef3 clang-cl: Warn about /U flags that look like filenames (PR31662)
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 the '/U' option, which is probably not what the user
wanted. Add a warning about this.

Differential Revision: https://reviews.llvm.org/D29198

llvm-svn: 293305
2017-01-27 17:09:41 +00:00
Chandler Carruth 5b4081198a Address review comments on r290392:
- Don't break using '-mllvm -disable-llvm-optzns' (yet).
- Don't add support for '-mllvm -disable-llvm-passes'.

This is important for LLVM 4 as we haven't yet really told folks this is
coming. I'll add release notes about this.

I've also added some explicit testing of this so its more obvious what
is happening here.

llvm-svn: 291850
2017-01-12 22:40:13 +00:00
Reid Kleckner 1b576eb0b3 Support -fno-delayed-template-parsing in clang-cl.exe
Summary:
This change adds support for the -fno-delayed-template-parsing option in
clang-cl.exe. This allows developers using clang-cl.exe to opt out of
emulation of MSVC's non-conformant template instantiation implementation
while continuing to use clang-cl.exe for its emulation of cl.exe
command-line options. The default behavior of clang-cl.exe
(-fdelayed-template-parsing) is unchanged.

The MSVC Standard Library implementation uses clang-cl.exe with this
switch in its tests to ensure that the library headers work on compilers
with the conformant two-phase-lookup behavior.

Reviewers: majnemer, cfe-commits, DaveBartolomeo

Differential Revision: https://reviews.llvm.org/D22275

llvm-svn: 290990
2017-01-04 19:15:53 +00:00
Chandler Carruth 93786da2cb Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.
Much to my surprise, '-disable-llvm-optzns' which I thought was the
magical flag I wanted to get at the raw LLVM IR coming out of Clang
deosn't do that. It still runs some passes over the IR. I don't want
that, I really want the *raw* IR coming out of Clang and I strongly
suspect everyone else using it is in the same camp.

There is actually a flag that does what I want that I didn't know about
called '-disable-llvm-passes'. I suspect many others don't know about it
either. It both does what I want and is much simpler.

This removes the confusing version and makes that spelling of the flag
an alias for '-disable-llvm-passes'. I've also moved everything in Clang
to use the 'passes' spelling as it seems both more accurate (*all* LLVM
passes are disabled, not just optimizations) and much easier to remember
and spell correctly.

This is part of simplifying how Clang drives LLVM to make it cleaner to
wire up to the new pass manager.

Differential Revision: https://reviews.llvm.org/D28047

llvm-svn: 290392
2016-12-23 00:23:01 +00:00
Bob Haarman 2fae56fce4 make -fprofile-instr-generate and -fprofile-instr-use work with clang-cl
Summary: Makes -fprofile-instr-generate and -fprofile-instr-use work
with clang-cl so that profile-guided optimization can be used.

Differential Revision: https://reviews.llvm.org/D27086

llvm-svn: 288230
2016-11-30 03:25:36 +00:00
Hans Wennborg 02d03befb9 clang-cl: Expose the -flto option
We could hook up /GL as an alias for -flto, but that might be
confusing, as clang-cl in that mode would not be drop-in compatible
with cl.exe /GL, as it requires the linker to be lld.

Exposing -flto seems like a less confusing way to expose this
functionality.

llvm-svn: 283255
2016-10-04 21:00:57 +00:00
Reid Kleckner a98496e6b0 [clang-cl] Accept the joined equals version of -resource-dir=
lib/Tooling injects this argument without regard for what driver syntax
is in use.

llvm-svn: 281550
2016-09-14 22:31:24 +00:00
Reid Kleckner b6bee5164d Make -fstandalone-debug and -flimit-debug-info available in clang-cl
Our limited debug info optimizations are breaking down at DLL
boundaries, so we're going to evaluate the size impact of these
settings, and possibly change the default.

Users should be able to override our settings, though.

llvm-svn: 281056
2016-09-09 16:42:50 +00:00
Pierre Gousseau 209b6e2e78 [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.
Checking for the type of the command line tokenizer should not be the criteria to enable support for the CL environment variable, this change checks that we are in clang-cl mode instead.

Differential Revision: https://reviews.llvm.org/D23503

llvm-svn: 280702
2016-09-06 10:48:27 +00:00
Nico Weber 9084adc290 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

llvm-svn: 279872
2016-08-26 21:51:14 +00:00
Nico Weber 66a1cbce30 clang-cl: Accept MSVC2015's '/utf-8' flag.
Clang always behaves as if that's passed, so just ignore the flag.

llvm-svn: 279869
2016-08-26 21:26:29 +00:00
Nico Weber ebe8d627c1 clang-cl: Accept MSVC 2015's `/execution-charset:utf-8` flag.
Also makes -fexec-charset accept utf-8 case-insensitively.
Like https://reviews.llvm.org/D23807, but for execution-charset.
Also replace a few .lower() comparisons with equals_lower().

https://reviews.llvm.org/D23938

llvm-svn: 279866
2016-08-26 21:11:43 +00:00
Hans Wennborg b30f4370a5 Add support for -fdiagnostics-absolute-paths: printing absolute paths in diagnostics
Differential Revision: https://reviews.llvm.org/D23816

llvm-svn: 279827
2016-08-26 15:45:36 +00:00
Adrian McCarthy 084148fcc3 Omit column info for CodeView by default
Clang tracks only start columns, not start-end ranges. CodeView allows for that, but the VS debugger doesn't handle anything less than a complete range well--it either highlights the wrong part of a statement or truncates source lines in the assembly view. It's better to have no column information at all.

So by default, we'll omit the column information for CodeView targeting Windows.

Since the column info is still useful for sanitizers, I've promoted -gcolumn-info (and -gno-column-info) to a CoreOption and added a couple tests to make sure that works for clang-cl.

Differential Revision: https://reviews.llvm.org/D23720

llvm-svn: 279765
2016-08-25 18:24:35 +00:00
Nico Weber 8531e4912b clang-cl: Make /Brepro actually work.
/Brepro means we want reproducible builds, i.e. we _don't_ want the timestamp
that's needed to be compatible with the incremental linker.

https://reviews.llvm.org/D23805

llvm-svn: 279555
2016-08-23 19:32:02 +00:00
Nico Weber 97f446c042 clang-cl: Accept MSVC 2015's `/source-charset:utf-8` flag.
clang already treats all inputs as utf-8. Warn if anything but utf-8 is passed.

Do this by mapping source-charset to finput-charset, which already behaves like
this. Slightly tweak finput-charset to accept "utf-8" case-insensitively. This
matches gcc's and cl.exe's behavior, and IANA says that character set names are
case-insensitive.

https://reviews.llvm.org/D23807

llvm-svn: 279531
2016-08-23 16:47:09 +00:00
Reid Kleckner bab5a5d704 [clang-cl] Make -gline-tables-only imply -gcodeview
It's surprising that you have to pass /Z7 in addition to -gcodeview to
get debug info. The sanitizer runtime, for example, expects that if the
compiler supports the -gline-tables-only flag, then it will emit debug
info.

llvm-svn: 278139
2016-08-09 17:23:56 +00:00
David Majnemer 58fab355e2 [clang-cl] Add support for /Zd
MASM (ML.exe and ML64.exe) and older versions of MSVC (CL.exe) support a
flag called /Zd which is more-or-less -gline-tables-only.

It seems nicer to support this flag instead of exposing
-gline-tables-only.

llvm-svn: 274991
2016-07-09 21:49:16 +00:00
David Majnemer 093012bf6e [clang-cl] Implement support for /std
/std: supports two arguments, c++14 and c++latest.  Currently, c++latest
maps to c++1z but this might change down the road.

llvm-svn: 273841
2016-06-27 02:32:12 +00:00
Hans Wennborg 44d061a471 Add support for /Ob1 and -finline-hint-functions flags
Add support for /Ob1 (and equivalent -finline-hint-functions), which enable
inlining only for functions marked inline, either explicitly (via inline
keyword, for example), or implicitly (function definition in class body,
for example).

This works by enabling inlining pass, and adding noinline attribute to
every function not marked inline.

Patch by Rudy Pons <rudy.pons@ilod.org>!

Differential Revision: http://reviews.llvm.org/D20647

llvm-svn: 273440
2016-06-22 16:56:16 +00:00
Etienne Bergeron e28e7f234d Add support to clang-cl driver for /GS switch
Summary:
This patch is adding command-line support for the MSVC buffer security check.

The buffer security check is turned on with the '/GS' compiler switch.
https://msdn.microsoft.com/en-us/library/8dbf701c.aspx

The MSVC buffer security check in implemented here:
http://reviews.llvm.org/D20346

Reviewers: hans, rnk

Subscribers: chrisha, cfe-commits, rnk, hans, thakis

Differential Revision: http://reviews.llvm.org/D20347

llvm-svn: 272832
2016-06-15 20:34:33 +00:00
Hans Wennborg 92375f55ed clang-cl: Support -resource-dir option (PR28074)
It's useful e.g. for distributed build systems.

llvm-svn: 272583
2016-06-13 20:31:30 +00:00
Hans Wennborg debfed9ef0 clang-cl: Fix unused argument warning when combining /O2 and /Ob2
llvm-svn: 270642
2016-05-25 00:43:45 +00:00
Hans Wennborg 3270bdbb03 clang-cl: Bake /Ob0 and /Ob2 into the general /O option handling
This is a follow-up to r270609, wherein I forgot that /O options can
be combined, and e.g. /Odb2 is a valid combination.

llvm-svn: 270614
2016-05-24 21:23:29 +00:00
Hans Wennborg 7a00888a08 [Driver] Add support for -finline-functions and /Ob2 flags
-finline-functions and /Ob2 are currently ignored by Clang. The only way to
enable inlining is to use the global O flags, which also enable other options,
or to emit LLVM bitcode using Clang, then running opt by hand with the inline
pass.

This patch allows to simply use the -finline-functions flag (same as GCC) or
/Ob2 in clang-cl mode to enable inlining without other optimizations.

This is the first patch of a serie to improve support for the /Ob flags.

Patch by Rudy Pons <rudy.pons@ilod.org>!

Differential Revision: http://reviews.llvm.org/D20576

llvm-svn: 270609
2016-05-24 20:40:51 +00:00
Adrian McCarthy e4b26fc7a7 Get default -fms-compatibility-version from cl.exe's version
-fms-compatibility-version was defaulting to 18 (VS 2013), which is a pain if your environment is pointing to version 19 (VS 2015) libraries.

If cl.exe can be found, this patch uses its version number as the default instead. It re-uses the existing code to find the Visual Studio binaries folder and WinAPI methods to check its version. You can still explicitly specify a compatibility version on the command line. If you don't have cl.exe, this should be a no-op and you'll get the old default of 18.

This affected the tests, which assumed that if you didn't specific a version, that it would default to 18, but this won't be true for all machines. So a couple test cases had to be eliminated and a couple others had to be tweaked to allow for various outputs.

Addresses: https://llvm.org/bugs/show_bug.cgi?id=27215

Differential Revision: http://reviews.llvm.org/D20136

llvm-svn: 269515
2016-05-13 23:20:11 +00:00
Ismail Donmez f677cd539f Fix testcase for the LLVM_LIBDIR_SUFFIX=64 case. Fallout from r266108.
llvm-svn: 266324
2016-04-14 15:32:24 +00:00
NAKAMURA Takumi 0d8d1d1cb2 clang/test/Driver/cl-options.c: Fix an expression to recognize dos r'\\'.
llvm-svn: 266154
2016-04-13 00:22:25 +00:00
Nico Weber fd3e1ad0ce clang-cl: Remove -isystem, add -imsvc.
r260990 exposed -isystem in clang-cl. -isystem adds a directory to the front of
the system include search path. The idea was to use this to point to a hermetic
msvc install, but as it turns out this doesn't work: -isystem then adds the
hermetic headers in front of clang's builtin headers, and clang's headers that
are supposed to wrap msvc headers (say, stdarg.h) aren't picked up at all
anymore.

So revert that, and instead expose -imsvc which works as if the passed
directory was part of %INCLUDE%: The header is treated as a system header, but
it is searched after clang's lib/Header headers.

Fixes half of PRPR26751.

llvm-svn: 266108
2016-04-12 19:04:37 +00:00
Nico Weber c8b31f30ad Revert 266090, needs more testing first.
llvm-svn: 266091
2016-04-12 16:52:30 +00:00
Nico Weber b790d4fd6c clang-cl: Expose -nostdlibinc.
llvm-svn: 266090
2016-04-12 16:38:07 +00:00
Nico Weber 4884dcf709 clang-cl: Silently ignore /d2FastFail flag.
It's some debugging flag for cl.exe related to how it writes crash dumps.

llvm-svn: 264774
2016-03-29 19:41:02 +00:00
Nico Weber 9c3fca3698 clang-cl: Don't warn about /Oy- being unused in 64-bit builds.
http://reviews.llvm.org/D18392

llvm-svn: 264163
2016-03-23 15:37:41 +00:00
Nico Weber 32b70e0dcf clang-cl: Move /FC from "Unsupported" to "Ignored" list.
/FC affects if diagnostics print with full paths and if __FILE__ expands with a
full path.  clang-cl does both of these two by default.

llvm-svn: 263953
2016-03-21 17:19:31 +00:00
Reid Kleckner 72a9d15aba [clang-cl] Allow use of -gline-tables-only
llvm-svn: 263816
2016-03-18 18:42:56 +00:00
David Majnemer cd5855e354 [clang-cl] /EHc should not effect functions with explicit exception specifications
Functions with an explicit exception specification have their behavior
dictated by the specification.  The additional /EHc behavior only comes
into play if no exception specification is given.

llvm-svn: 262198
2016-02-29 01:40:36 +00:00
David Majnemer a7bdc5ad54 Don't enable /GX by default
The /GX flag is disabled unless explicitly specified on the command
line.  This partially addresses PR26698.

llvm-svn: 261537
2016-02-22 17:44:51 +00:00
David Majnemer b880909ab5 [MSVC Compat] Add support for /GX, /GX-
These are legacy flags which map to /EHsc and /EHs-c- respectively.

llvm-svn: 261424
2016-02-20 09:23:44 +00:00
Nico Weber 8714c125e8 clang-cl: Expose -isystem.
Like cl.exe, clang-cl allows adding system include directories via the
INCLUDE env var.  Having a driver flag for this functionality is useful,
so add this too.

(In the future, we probably also want to have a flag alternative to
VCINSTALLDIR as used in MSVCToolChain::getVisualStudioBinaries(), and
a way to override the registry accesses in MSVCToolChain::getWindowsSDKDir()
-- maybe -ivcroot= and -iwinsdkroot=?).

llvm-svn: 260990
2016-02-16 19:05:50 +00:00
Reid Kleckner 9ce06a4ab8 [clang-cl] /Z7 now generates normal debug info, not just line info
Previously LLVM could not process any debug info we produced, so it
didn't make sense to spend time generating it. Now that it has primitive
support for local variable info, it does make sense to generate normal
debug info.

llvm-svn: 260435
2016-02-10 21:28:38 +00:00
David Majnemer 259d71a464 [MSVC Compat] Don't omit frame pointers if /Oy- is specified before /O2
Microsoft's documentation states that specifying
/Oy- after the /O[12x] options disables frame-pointer omission.
What it does *not* state is that it also disables frame-pointer omission
if /Oy- is specified before /O[12x].

llvm-svn: 258447
2016-01-21 23:01:11 +00:00
Hans Wennborg 94d6a71363 Follow-up to r257537: add test that majnemer asked about
llvm-svn: 257541
2016-01-12 23:31:58 +00:00
Hans Wennborg 21d73d2e0a clang-cl: Support /Dfoo#bar (PR25984)
Such flags will now be translated to -Dfoo=bar.

llvm-svn: 257537
2016-01-12 23:17:03 +00:00
David Majnemer 2b9349db38 [clang-cl] Add support for /Brepro
The /Brepro flag controls whether or not the compiler should embed
timestamps into the object file.  Object files which do not embed
timestamps are not suitable for incremental linking but are suitable for
hermetic build systems and staged self-hosts of clang.

A normal clang spelling of this flag has been added,
-mincremental-linker-compatible.

llvm-svn: 256204
2015-12-21 22:09:34 +00:00
Nico Weber 0d10b2cf3c clang-cl: Add an alias for /wd4100
llvm-svn: 255655
2015-12-15 17:07:16 +00:00
Hans Wennborg 4ae76c2692 clang-cl: make /Wall turn on both -Wall and -Wextra (PR25563)
The documentation suggests /Wall should really turn on -Wextra and any
other warnings that are not enabled by default. That would correspond
to Clang's -Weverything, but is probably not what users want.

llvm-svn: 255524
2015-12-14 18:46:11 +00:00
Nico Weber c80367417c [clang-cl] Let /W4 map to -Wall -Wextra instead of just -Wall.
There's no way to make a flag alias to two flags, so add a /WCL4 flag that
maps to the All, Extra diag groups.  Fixes PR25563.

http://reviews.llvm.org/D15350

llvm-svn: 255382
2015-12-11 22:31:16 +00:00