Richard Smith [Wed, 25 Feb 2015 22:20:13 +0000 (22:20 +0000)]
[modules] Even if we already have a definition of a class, loading in another
one can give us more lookup results (due to implicit special members). Be sure
to complete the redecl chain for every kind of DeclContext before performing a
lookup into it, rather than only doing so for NamespaceDecls.
Ben Langmuir [Wed, 25 Feb 2015 20:09:06 +0000 (20:09 +0000)]
Allow (Object *)kMyGlobalCFObj casts without bridging
Previously we allowed these casts only for constants declared in system
headers, which we assume are retain/release-neutral. Now also allow them
for constants in user headers, treating them as +0. Practically, this
means that we will now allow:
id x = (id)kMyGlobalConst;
But unlike with system headers we cannot mix them with +1 values:
id y = (id)(b ? kMyGlobalConst : [Obj newValAtPlusOne]); // error
id z = (id)(b ? kSystemGlobalConst: [Obj newValAtPlusOne]); // OK
Reid Kleckner [Wed, 25 Feb 2015 19:17:50 +0000 (19:17 +0000)]
clang-cl: Ignore /Fd silently
While it's true that we don't create the PDB as requested on the command
line, this is a well-documented limitation. Warning about it doesn't
help people using legacy build systems with clang-cl, and it makes the
clang-cl self-host very noisy.
Reid Kleckner [Wed, 25 Feb 2015 19:17:45 +0000 (19:17 +0000)]
Reland r230446, "MS ABI: Try to respect external AST source record layouts"
It broke test/PCH/headersearch.cpp because it was using -Wpadding, which
only works for Itanium layout. Before this commit, we would use Itanium
record layout when using PCH, which is crazy. Now that the test uses an
explicit Itanium triple, we can reland.
Reid Kleckner [Wed, 25 Feb 2015 19:04:51 +0000 (19:04 +0000)]
Use Itanium triple in test using -Wpadding
-Wpadding is not implemented in the Microsoft record layout builder.
This test only passes on Windows because PCH forces us to use the
Itanium record layout builder. I'm about to fix that, so change the
test to not rely on that ridiculous behavior.
Nico Weber [Wed, 25 Feb 2015 16:25:00 +0000 (16:25 +0000)]
Reland r230460 with a test fix for -Asserts builds.
Original CL description:
Produce less broken basic block sequences for __finally blocks.
The way cleanups (such as PerformSEHFinally) get emitted is that codegen
generates some initialization code, then calls the cleanup's Emit() with the
insertion point set to a good place, then the cleanup is supposed to emit its
stuff, and then codegen might tack in a jump or similar to where the insertion
point is after the cleanup.
The PerformSEHFinally cleanup tries to just stash away the block it's supposed
to codegen into, and then does codegen later, into that stashed block. However,
after codegen'ing the __finally block, it used to set the insertion point to
the finally's continuation block (where the __finally cleanup goes when its body
is completed after regular, non-exceptional control flow). That's not correct,
as that block can (and generally does) already ends in a jump. Instead,
remember the insertion point that was current before the __finally got emitted,
and restore that.
The original commit failed to handle "shift assign" (<<=), which
broke the test mentioned in r228406. This is now fixed and the
test added to the lit tests under SemaOpenCL.
*** Original commit message from r228382 ***
OpenCL: handle shift operator with vector operands
Introduce a number of checks:
1. If LHS is a scalar, then RHS cannot be a vector.
2. Operands must be of integer type.
3. If both are vectors, then the number of elements must match.
Relax the requirement for "usual arithmetic conversions":
When LHS is a vector, a scalar RHS can simply be expanded into a
vector; OpenCL does not require that its rank be lower than the LHS.
For example, the following code is not an error even if the implicit
type of the constant literal is "int".
char2 foo(char2 v) { return v << 1; }
Consolidate existing tests under CodeGenOpenCL, and add more tests
under SemaOpenCL.
Nico Weber [Wed, 25 Feb 2015 04:05:18 +0000 (04:05 +0000)]
Produce less broken basic block sequences for __finally blocks.
The way cleanups (such as PerformSEHFinally) get emitted is that codegen
generates some initialization code, then calls the cleanup's Emit() with the
insertion point set to a good place, then the cleanup is supposed to emit its
stuff, and then codegen might tack in a jump or similar to where the insertion
point is after the cleanup.
The PerformSEHFinally cleanup tries to just stash away the block it's supposed
to codegen into, and then does codegen later, into that stashed block. However,
after codegen'ing the __finally block, it used to set the insertion point to
the finally's continuation block (where the __finally cleanup goes when its body
is completed after regular, non-exceptional control flow). That's not correct,
as that block can (and generally does) already ends in a jump. Instead,
remember the insertion point that was current before the __finally got emitted,
and restore that.
Adrian Prantl [Wed, 25 Feb 2015 01:31:45 +0000 (01:31 +0000)]
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.
This reapplies r230044 with a fixed configure+make build and updated
dependencies and testcase requirements. Over the last iteration this
version adds
- missing target requirements for testcases that specify an x86 triple,
- a missing clangCodeGen.a dependency to libClang.a in the make build.
Richard Smith [Wed, 25 Feb 2015 00:56:02 +0000 (00:56 +0000)]
[modules] Fix a bug that would result in a build with P paths through a module
graph with M modules to take O(P) time, not just O(M) time, when using explicit
module builds.
Justin Bogner [Tue, 24 Feb 2015 21:49:28 +0000 (21:49 +0000)]
InstrProf: Simplify a couple of tests after r230383
Most of the checks in these two tests were actually testing the
behaviour of the instrprof LLVM pass. Now that we're testing that
specifically in LLVM's test suite, it's better if we only test the
frontend's behaviour here.
Richard Smith [Tue, 24 Feb 2015 21:44:43 +0000 (21:44 +0000)]
PR22673 again: diagnose use of the used decl, not the found decl. This is also
wrong (DiagnoseUseOfDecl should take both), but it's more consistent with what
we do in other places.
Tim Northover [Tue, 24 Feb 2015 17:22:40 +0000 (17:22 +0000)]
ARM: Simplify PCS handling.
The backend should now be able to handle all AAPCS rules based on argument
type, which means Clang no longer has to duplicate the register-counting logic
and the CodeGen can be significantly simplified.
Michael Wong [Tue, 24 Feb 2015 13:34:20 +0000 (13:34 +0000)]
Commit patch for PR19649. Set the correct sign of wide character for literals based on underlying type of wchar_t.
Reviewed:
http://reviews.llvm.org/D7559
Patch by Rachel Craig; Test cases by Hubert Tong.
Alexey Bataev [Tue, 24 Feb 2015 12:55:09 +0000 (12:55 +0000)]
[OPENMP] Update codegen for 'omp flush' directive.
__kmpc_omp_flush() runtime library now has only one argument and is not a vararg
anymore. This update makes the codegen compatible with these changes.
MSVC does not support C99 _Complex.
ICC, however, does support it on windows x86_64, and treats it, for purposes of parameter passing, as equivalent to a struct containing two fields (for the real and imaginary part).
Ben Langmuir [Tue, 24 Feb 2015 04:58:15 +0000 (04:58 +0000)]
Don't load Framework module.map files when searching subdirectories
This would cause frameworks to have spurious "redefinition" errors if
they had both a (legacy) "module.map" and a (new) "module.modulemap" file and we
happened to do a sub-directory search in that directory using a
non-framework include path (e.g. -Ifoo/ -Ffoo/). For migration
purposes it's very handy that the compiler will prefer the new spelling
of the filename and not look at the old one if it doesn't need to.
Adrian Prantl [Tue, 24 Feb 2015 04:25:59 +0000 (04:25 +0000)]
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.
Justin Bogner [Tue, 24 Feb 2015 04:13:56 +0000 (04:13 +0000)]
InstrProf: Make sure counts in lambdas don't escape to the parent scope
When generating coverage maps, we were traversing the body as if it
were part of the parent function, but this doesn't make sense since
we're currently counting lambdas as separate functions.
Richard Smith [Tue, 24 Feb 2015 03:30:14 +0000 (03:30 +0000)]
[modules] Properly check whether a declaration is std::initializer_list. This
bug is not actually modules-specific, but it's a little tricky to tickle it
outside of modules builds, so submitting with the reduced testcase I have.
Richard Smith [Tue, 24 Feb 2015 02:44:23 +0000 (02:44 +0000)]
[modules] Ensure we've imported all declarations of a template before
attempting to lazily deserialize its specializations; otherwise, there might be
pending specializations that we don't know about yet.
Dmitri Gribenko [Tue, 24 Feb 2015 01:06:22 +0000 (01:06 +0000)]
Restore the libc++ definition of max_align_t on Apple platforms
Clang has introduced ::max_align_t in stddef.h in r201729, but libc++ was
already defining std::max_align_t on Darwin because there was none in the
global namespace. After that Clang commit though, libc++ started defining
std::max_align_t to be a typedef for ::max_align_t, which has a different
definition. This changed the ABI. This commit restores the previous
definition.
Richard Smith [Mon, 23 Feb 2015 21:16:05 +0000 (21:16 +0000)]
Improve declaration / expression disambiguation around ptr-operators, and use
the presence of an abstract declarator with a ptr-operator as proof that a
construct cannot parse as an expression to improve diagnostics along error
recovery paths.
Only lower __builtin_setjmp / __builtin_longjmp to
llvm.eh.sjlj.setjmp / llvm.eh.sjlj.longjmp, if the backend is known to
support them outside the Exception Handling context. The default
handling in LLVM codegen doesn't work and will create incorrect code.
The ARM backend on the other hand will assert if the intrinsics are
used.
Justin Bogner [Mon, 23 Feb 2015 19:27:00 +0000 (19:27 +0000)]
InstrProf: Run clang-format to fix some strange indentation (NFC)
Somehow this file ended up with a strange hybrid of the old "indent
inside a namespace" style and the new "don't", giving us a wonderful
two-space indent starting halfway through a namespace. Fix it.
Reid Kleckner [Mon, 23 Feb 2015 19:25:48 +0000 (19:25 +0000)]
-fms-extensions: Bump the default _MSC_VER from 1700 to 1800, aka VS2013
VS 2013 is the minimum supported version, so it's reasonable for Clang
to simulate this by default. This also simplifies the clang-cl
self-host, since we have the 18.00 version check.
Ed Schouten [Mon, 23 Feb 2015 09:12:31 +0000 (09:12 +0000)]
Add C11 *_DECIMAL_DIG.
Before C11 there was only the DECIMAL_DIG definition. As of C11, we now
have one definition per floating point type (e.g. DBL_DECIMAL_DIG).
Change the existing code to define the new versions. To remain backward
compatible, define __DECIMAL_DIG__ as __LDBL_DECIMAL_DIG__.
Also update the tests. It seems that some of the existing test vectors
were incorrect. Change all tests for __DECIMAL_DIG__ to expect
__LDBL_DECIMAL_DIG__. Add tests for *_DECIMAL_DIG for FreeBSD/amd64, as
I happen to have such a system laying around. I've validated that the
values are in sync with <float.h>.
Larisse Voufo [Sun, 22 Feb 2015 06:36:53 +0000 (06:36 +0000)]
Relax the requirement on sized deallocation a bit: Default on unsized delete if sized delete is not provided in global scope, and -fdefine-sized-deallocation option is disabled.
Richard Smith [Sat, 21 Feb 2015 02:45:19 +0000 (02:45 +0000)]
Cleanup: remove artificial division between lookup results and const lookup
results. No-one was ever modifying a lookup result, and it would not be
reasonable to do so.
Richard Smith [Sat, 21 Feb 2015 02:31:57 +0000 (02:31 +0000)]
Revert r167816 and replace it with a proper fix for the issue: do not
invalidate lookup_iterators and lookup_results for some name within a
DeclContext if the lookup results for a *different* name change.
Hans Wennborg [Sat, 21 Feb 2015 01:07:24 +0000 (01:07 +0000)]
Improve diagnostic when failing to synthesize implicit member due to dllexport (PR22591)
This is only a problem in C++03 mode targeting MS ABI (MinGW doesn't
export inline methods, and C++11 marks these methods implicitly
deleted).
Since targeting the MS ABI in pre-C++11 mode is a rare configuration,
this will probably not get fixed, but we can at least have a better
error message.
[Objective-C]. Provide a new formatting kind, "os_trace" which
can take a "const char*" format but supports standard printf
and CF/NS types . rdar://19904147
Adrian Prantl [Fri, 20 Feb 2015 23:34:26 +0000 (23:34 +0000)]
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.
Adrian Prantl [Fri, 20 Feb 2015 21:53:12 +0000 (21:53 +0000)]
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.
Ben Langmuir [Fri, 20 Feb 2015 21:46:39 +0000 (21:46 +0000)]
Don't try to rebuild modules on umbrella header mismatch
There are two issues here:
1) It's too late to rebuild at this point, because we won't go through
removeModules and when we try to reload the new .pcm we'll get the old
one instead. We might be able to call removeModules after an OutOfDate
here, but I'm not yet confident that it is always safe to do so.
2) In practice, this check fails spuriously when the umbrella header
appears to change because of a VFS change that means it maps to a
different copy of the same file. Because of this, we just skip the
check for now.
Implement Control Flow Integrity for virtual calls.
This patch introduces the -fsanitize=cfi-vptr flag, which enables a control
flow integrity scheme that checks that virtual calls take place using a vptr of
the correct dynamic type. More details in the new docs/ControlFlowIntegrity.rst
file.
It also introduces the -fsanitize=cfi flag, which is currently a synonym for
-fsanitize=cfi-vptr, but will eventually cover all CFI checks implemented
in Clang.
Adrian Prantl [Fri, 20 Feb 2015 19:44:52 +0000 (19:44 +0000)]
Wrap clang module files in a Mach-O, ELF, or COFF container.
This is a necessary prerequisite for debugging with modules.
The .pcm files become containers that hold the serialized AST which allows
us to store debug information in the module file that can be shared by all
object files that were built importing the module.
Manuel Klimek [Fri, 20 Feb 2015 11:44:41 +0000 (11:44 +0000)]
Add -fno-implicit-modules.
If this flag is set, we error out when a module build is required. This is
useful in environments where all required modules are passed via -fmodule-file.