David Majnemer [Fri, 24 Oct 2014 19:49:04 +0000 (19:49 +0000)]
CodeGen: GLValue exprs in template parameters should have reference type
This fixes a corner-case where __uuidof as a template argument would
result in us trying to emit a GLValue as an RValue. This would lead to
a crash down the road.
Daniel Sanders [Fri, 24 Oct 2014 15:30:16 +0000 (15:30 +0000)]
[mips] Mark aggregate arguments passed in registers with the inreg attribute
Summary:
This allows us to easily identify them in the backend which in turn allows us
to handle them correctly for big-endian targets (where they must be shifted
into the upper bits of the register).
Daniel Sanders [Fri, 24 Oct 2014 14:42:42 +0000 (14:42 +0000)]
[mips] Promote all integral/enumeration types to the GPR width
Summary:
Ensure all integral/enumeration types are appropriately annotated with
signext/zeroext. In particular, i32 now has these attributes when using the
N32/N64 ABI. This paves the way for accurately representing the way the
N32/N64 ABI's promotes integer arguments to i64.
Olivier Goffart [Fri, 24 Oct 2014 13:52:55 +0000 (13:52 +0000)]
Fix initializing TypeOfTypeLoc
This fixes a crash in the RecursiveASTVisitor on such code
__typeof__(struct F*) var[invalid];
The UnderlyingTInfo of a TypeOfTypeLoc was left uninitialized when
created from ASTContext::getTrivialTypeSourceInfo
This lead to a crash in RecursiveASTVisitor when trying to access it.
Oliver Stannard [Fri, 24 Oct 2014 11:28:47 +0000 (11:28 +0000)]
[Thumb] Clang thinks "char" is signed when using a thumb triple
'char' is unsigned on all ARM and Thumb architectures. Clang gets this
right for ARM, and for thumb when using and arm triple and the -mthumb
option, but gets it wrong for thumb triples. This fixes that.
This is a very basic toolchain. It supports cross-compiling Windows (primarily
inspired by the WoA target). It is meant to use clang with the LLVM IAS and a
binutils ld-compatible interface for the linker (eventually to be lld). It does
not perform any "standard" GCC lookup, nor does it perform any special
adjustments given that it is expected to be used in an environment where the
user is using MSVCRT (and as such Visual Studio headers) and the Windows SDK.
The primary runtime library is expected to be compiler-rt and the C++
implementation to be libc++.
It also expects that a sysroot has been setup given the usual Unix semantics
(standard C headers in /usr/include, all the import libraries available in
/usr/lib). It also expects that an entry point stub is present in /usr/lib
(crtbegin.obj for executables, crtbeginS.obj for shared libraries).
The entry point stub is responsible for running any GNU constructors.
Hans Wennborg [Thu, 23 Oct 2014 22:40:46 +0000 (22:40 +0000)]
Don't emit strong vtable definitions for imported classes with key functions (PR21355)
Clang would previously assert on the following code when targeting MinGW:
struct __declspec(dllimport) S {
virtual ~S();
};
S::~S() {}
Because ~S is a key function and the class is dllimport, we would try to emit a
strong definition of the vtable, with dllimport - which is a conflict. We
should not emit strong vtable definitions for imported classes.
Justin Bogner [Thu, 23 Oct 2014 22:20:11 +0000 (22:20 +0000)]
Driver: Include driver diagnostics when we --serialize-diagnostics
Currently, when --serialize-diagnostics is passed this only includes
the diagnostics from clang -cc1, and driver diagnostics are
dropped. This causes issues for tools that use the serialized
diagnostics, since stderr is lost and these diagnostics aren't seen at
all.
We handle this by merging the diagnostics from the CC1 process and the
driver diagnostics into a single file when the driver invokes CC1.
patch to issue warning on comparing parameters with
nonnull attribute when comparison is always
true/false. Patch by Steven Wu with few fixes and minor
refactoring and adding tests by me. rdar://18712242
Ben Langmuir [Thu, 23 Oct 2014 18:05:36 +0000 (18:05 +0000)]
Add a "signature" to AST files to verify that they haven't changed
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs)
is not stable, it is not safe to load an AST file that depends on
another AST file that has been rebuilt since the importer was built,
even if "nothing changed". We previously used size and modtime to check
this, but I've seen cases where a module rebuilt quickly enough to foil
this check and caused very hard to debug build errors.
To save cycles when we're loading the AST, we just generate a random
nonce value and check that it hasn't changed when we load an imported
module, rather than actually hash the whole file.
This is slightly complicated by the fact that we need to verify the
signature inside addModule, since we might otherwise consider that a
mdoule is "OutOfDate" when really it is the importer that is out of
date. I didn't see any regressions in module load time after this
change.
David Blaikie [Thu, 23 Oct 2014 16:39:49 +0000 (16:39 +0000)]
DebugInfo: Correctly describe the lexical decl context of static member variable definitions.
The previous IR representation used the non-lexical decl context, which
placed the definitions in the same scope as the declarations (ie: within
the class) - this was hidden by the fact that LLVM currently doesn't
respect the context of global variable definitions at all, and always
puts them at the top level (as direct children of the compile_unit).
Having the correct lexical scope improves source fidelity and simplify
backend global variable emission (with changes coming shortly).
Doing something similar for non-member global variables would help
simplify/cleanup things further (see FIXME in the commit) and provide
similar source fidelity benefits to the final debug info.
Richard Smith [Thu, 23 Oct 2014 02:01:19 +0000 (02:01 +0000)]
Refactor implementation of 'exclude header'.
This was not a real header role, and was never exposed to clients of ModuleMap.
Remove the enumeration value for it and track it as marking the header as
'known' rather than creating an extra KnownHeader entry that *every single*
client ignores.
Alexey Samsonov [Thu, 23 Oct 2014 00:46:10 +0000 (00:46 +0000)]
Revert r218541 - Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is provided.
This is a sad thing to do, but all the alternatives look ugly.
Looks like there are legitimate cases when users may want to link
with sanitizer runtimes *and* -nodefaultlibs (and ensure they provide
replacements for system libraries). For example, this happens in libc++
test suite.
"-nodefaultlibs" is told to link only the libraries explicitly provided
by the user, and providing "-fsanitize=address" is a clear indication of
intention to link with ASan runtime.
We can't easily introduce analogue of "-print-libgcc-name": linking with
sanitizers runtimes is not trivial: some runtimes are split into several
archive libraries, which are required to be wrapped in
-whole-archive/-no-whole-archive.
If "-fsanitize=whatever" and "-nodefaultlibs" are provided, system library
dependencies of sanitizer runtimes (-lc/-ldl/-lpthread/-lrt) will *not* be
linked, and user would have to link them in manually. Note that this can
cause problems, as failing to provide "-lrt" might lead to crashes in runtime
during ASan initialization. But looks like we should bite this bullet.
Richard Smith [Wed, 22 Oct 2014 23:50:56 +0000 (23:50 +0000)]
[modules] Add support for 'textual header' directives.
This allows a module to specify that it logically contains a file, but that
said file is non-modular and intended for textual inclusion. This allows
layering checks to work properly in the presence of such files.
Aaron Ballman [Wed, 22 Oct 2014 21:06:18 +0000 (21:06 +0000)]
Removing the setLBracLoc and setRBracLoc functions from CompoundStmt -- their only use was with the AST reader, and friendship can be used to handle that. Drive-by rename of "Brac" to "Brace" for the private data members. NFC.
Zachary Turner [Wed, 22 Oct 2014 20:40:43 +0000 (20:40 +0000)]
Make a good guess about where MSVC and Windows SDK libraries are for linking.
When a user has not configured a standard Visual Studio environment
by running vcvarsall, clang tries its best to find Visual Studio
include files and executables anyway. This patch makes clang also
try to find system and Windows SDK libraries for linking against,
as well.
Reviewed by: Hans Wennborg
Differential Revision: http://reviews.llvm.org/D5873
Zachary Turner [Wed, 22 Oct 2014 20:40:28 +0000 (20:40 +0000)]
Resubmit "Improve Windows toolchain support for non-standard environments."
This resubmits change r220226. That change broke the chromium
build bots because chromium it ships an hermetic MSVC toolchain
that it expects clang to fallback to by finding it on the path.
This patch fixes the issue by bumping up the prioritization of PATH
when looking for MSVC binaries.
Reviewed by: Hans Wennborg, Reid Kleckner
Differential Revision: http://reviews.llvm.org/D5892
David Blaikie [Wed, 22 Oct 2014 19:54:16 +0000 (19:54 +0000)]
Correct importing of the type of a TemplateArgument
It's not clear how this would be tested - I imagine we should have an
ASTImporter test that RAVs the new AST and checks that all the elements
in it are from this ASTContext and not the foreign one... but I know
little about the ASTImporter and how/where that testing might be done.
(post-commit review feedback from Richard Smith on r219900)
Alexey Samsonov [Wed, 22 Oct 2014 18:26:07 +0000 (18:26 +0000)]
SanitizerBlacklist: Use spelling location for blacklisting purposes.
When SanitizerBlacklist decides if the SourceLocation is blacklisted,
we need to first turn it into a SpellingLoc before fetching the filename
and scanning "src:" entries. Otherwise we will fail to fecth the
correct filename for function definitions coming from macro expansion.
Reid Kleckner [Wed, 22 Oct 2014 17:50:19 +0000 (17:50 +0000)]
Reland r219810 "Fix late template parsing leak with incremental processing"
Original message:
Add a second late template parser callback meant to cleanup any
resources allocated by late template parsing. Call it from the
Sema::ActOnEndOfTranslationUnit method after all pending template
instantiations have been completed. Teach Parser::ParseTopLevelDecl to
install the cleanup callback when incremental processing is enabled so
that Parser::TemplateIds can be freed.
Reid Kleckner [Wed, 22 Oct 2014 17:26:00 +0000 (17:26 +0000)]
MS ABI: Emit more canonical vbptr stores and loads
This eliminates some i8* GEPs and makes the IR that clang emits a bit
more canonical. More work is needed for vftables, but that isn't a clear
win so I plan to send it for review.
Diego Novillo [Wed, 22 Oct 2014 13:00:05 +0000 (13:00 +0000)]
Support using sample profiles with partial debug info (driver)
Summary:
When using a profile, we used to require the use -gmlt so that we could
get access to the line locations. This is used to match line numbers in
the input profile to the line numbers in the function's IR.
But this is actually not necessary. The driver can provide source
location tracking without the emission of debug information. In these
cases, the annotation 'llvm.dbg.cu' is missing from the IR, but the
actual line location annotations are still present.
This patch tells the driver to only emit source location tracking
when -fprofile-sample-use is present in the command line.
Richard Trieu [Wed, 22 Oct 2014 02:52:00 +0000 (02:52 +0000)]
Disable the uninitialized field warning in uninstantiated classes.
If a templated class is not instantiated, then the AST for it could be missing
some things that would throw the field checker off. Wait until specialization
before emitting these warnings.
This renames the Windows toolchain to MSVCToolChain. This is a preparatory step
for adding a CrossWindowsToolChain which uses clang/libc++/(ld/lld) without the
standard GCC toolchain lookup. NFC.
Richard Smith [Wed, 22 Oct 2014 02:05:46 +0000 (02:05 +0000)]
[modules] Initial support for explicitly loading .pcm files.
Implicit module builds are not well-suited to a lot of build systems. In
particular, they fare badly in distributed build systems, and they lead to
build artifacts that are not tracked as part of the usual dependency management
process. This change allows explicitly-built module files (which are already
supported through the -emit-module flag) to be explicitly loaded into a build,
allowing build systems to opt to manage module builds and dependencies
themselves.
This is only the first step in supporting such configurations, and it should
be considered experimental and subject to change or removal for now.
Richard Smith [Tue, 21 Oct 2014 23:01:04 +0000 (23:01 +0000)]
PR21327 / C++ DR1652 / C++ DR73: comparing a past-the-end pointer for one
complete object to a pointer to the start of another complete object does
not evaluate to the constant 'false'. All other comparisons between the
addresses of subobjects of distinct complete objects still do.
Aaron Ballman [Tue, 21 Oct 2014 19:24:06 +0000 (19:24 +0000)]
Follow-up commit to r211657 which introduced these macros, but not for MSVC. This turns out to break our freestanding tests on Windows when compiling in MSVC-compatible mode. It was decided (http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20141020/116942.html is the start of the thread) to support this as part of Clang's interface on all platforms.
Hal Finkel [Tue, 21 Oct 2014 19:20:21 +0000 (19:20 +0000)]
Treat -g1 as -gline-tables-only
-g1 on gcc (and also IBM's xlc) are documented to be very similar to
-gline-tables-only. Our -gline-tables-only might still be more verbose than -g1
on other compilers, but currently we treat -g1 as -g, and so we're producing
much more debug info at -g1 than everybody else. Treating -g1 as
-gline-tables-only brings us much closer to what everyone else is doing.
For more information, see the discussion on
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-October/039649.html
Justin Bogner [Tue, 21 Oct 2014 18:03:08 +0000 (18:03 +0000)]
Driver: Quote the command in crash reproduction scripts.
This fixes crash report generation when filenames have spaces. It also
removes an awkward workaround that quoted *some* arguments when
generating crash reports.
Justin Bogner [Tue, 21 Oct 2014 17:24:44 +0000 (17:24 +0000)]
Driver: Move crash report command mangling into Command::Print
This pushes the logic for generating a crash reproduction script
entirely into Command::Print, instead of Command doing half of the
work and then relying on textual substitution for the rest. This makes
this logic much easier to read and will simplify fixing a couple of
issues in this area.
Alexey Bataev [Tue, 21 Oct 2014 03:16:40 +0000 (03:16 +0000)]
[OPENMP] Codegen for 'private' clause in 'parallel' directive.
This patch generates some helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by default (with the default constructor, if any). In outlined function references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables and implicit barier is set by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables.
Differential Revision: http://reviews.llvm.org/D4752
Richard Smith [Mon, 20 Oct 2014 23:26:58 +0000 (23:26 +0000)]
Switch C compilations to C11 by default.
This is long-since overdue, and matches GCC 5.0. This should also be
backwards-compatible, because we already supported all of C11 as an extension
in C99 mode.
Hans Wennborg [Mon, 20 Oct 2014 23:26:03 +0000 (23:26 +0000)]
Revert "Improve Windows toolchain support for non-standard environments." (r220226)
In environments where PATH was set to point to the VS installation, Clang would
override that by looking in the registry and finding the latest VS installation.
If the environment is set up to point to a VS installation, that should take
precedence.
Justin Bogner [Mon, 20 Oct 2014 22:47:23 +0000 (22:47 +0000)]
Driver: Consolidate the logic for naming the module crashdump cache
List the module cache we use for crashdumps as a tempfile. This
simplifies how we pick up this directory when generating the actual
crash diagnostic and removes some duplicate logic.
Justin Bogner [Mon, 20 Oct 2014 21:47:56 +0000 (21:47 +0000)]
Driver: Name crashdump scripts after the first temp file
In practice there's only ever one temporary output file when
generating a crashdump, but even if there were many iterating over
each and creating a duplicate run script for each one wouldn't make
very much sense.
This updates the behaviour to only generate the script once, based on
the first filename.
This should make it more reasonable to generate extra output files to
include in the crashdump going forward, so I've also added a FIXME to
look into doing just that with the extra module crashdump files.