Sebastian Redl [Thu, 19 May 2011 05:13:44 +0000 (05:13 +0000)]
Reapply r121528, fixing PR9941 by delaying the exception specification check for destructors until the class is complete and destructors have been adjusted.
Sean Hunt [Wed, 18 May 2011 03:41:58 +0000 (03:41 +0000)]
Implement an additional fix for infinite recursion of deleted special
member functions by making sure that they're on the record before
checking for deletion.
Also make sure source locations are valid to avoid crashes.
Unfortunately, the declare-all-implicit-members approach is still
required in order to ensure that dependency loops do not result in
incorrectly deleting functions (since they are to be deleted at the
declaration point per the standard).
Sean Hunt [Wed, 18 May 2011 01:06:45 +0000 (01:06 +0000)]
Force declaration of implicit members in C++0x mode.
I hear at least one person crying out in anguish, but it's unfortunately
necessary to avoid infinite loops with mutually dependent constructors
trying to call each other and determine if they are deleted.
It might be possible to go back to the old behavior if we can implement
part-of-file lookups efficiently, or if a solution is discovered by
which we can safely detect and avoid infinite recusion.
1. We would assume that the length of the string literal token was at least 2
2. We would allocate a buffer with size length-2
And when the stars aligned (one of which would be an invalid source location due to stale PCH)
The length would be 0 and we would try to allocate a 4GB buffer.
Add checks for this corner case and a bunch of asserts.
(We really really should have had an assert for 1.).
Note that there's no test case since I couldn't get one (it was major PITA to reproduce),
maybe later.
John McCall [Tue, 17 May 2011 21:05:49 +0000 (21:05 +0000)]
Revert r131434, my commit disabling the complete-object constructor
optimization for abstract classes; there was a misunderstanding, and
it turns out that there are no kexts which rely on this.
Sean Hunt [Tue, 17 May 2011 20:44:39 +0000 (20:44 +0000)]
Add some more tests.
I have on that's #if 0'ed out, and I don't know why it's failing to
delete the constructor. I'd appreciate if someone familiar with access
control could look into ShouldDeleteDefaultConstructor - thanks.
Make the triple an explicit argument of FindTargetProgramPath.
Preserve the original triple in the NetBSD toolchain when using -m32 or
-m64 and the resulting effective target is different from the triple it
started with. This allows -m32 to use the same assembler/linking in
cross-compiling mode and avoids confusion about passing down target
specific flags in that case like --32.
Anders Carlsson [Mon, 16 May 2011 04:08:36 +0000 (04:08 +0000)]
Fix another regression from the "skip vtable pointer initialization"
optimization. Make sure to require a vtable when trying to get the address
of a VTT, otherwise we would never end up emitting the VTT.
John McCall [Sun, 15 May 2011 17:49:20 +0000 (17:49 +0000)]
Add a method for checking whether a function is one of the reserved global
placement allocation or deallocation functions. These functions cannot be
replaced by the user and are exempt from the normal requirements on
allocation functions (e.g. that they must return unaliased memory).
Douglas Gregor [Sun, 15 May 2011 17:27:27 +0000 (17:27 +0000)]
When checking a set of template parameter lists against a
nested-name-specifier, re-evaluate the nested-name-specifier as if we
were entering that context (which we did!), so that we'll resolve a
template-id to a particular class template partial
specialization. Fixes PR9913.
John McCall [Sun, 15 May 2011 07:14:44 +0000 (07:14 +0000)]
The array-size operand to a new-expression is not necessarily a size_t.
It can be larger, it can be smaller, it can be signed, whatever. Handle
all the crazy cases with grace and spirit.
John McCall [Sun, 15 May 2011 01:53:33 +0000 (01:53 +0000)]
Use arrays and SmallVectors instead of std::vectors when building function
types. Also, cache a translation of 'void' in CGM and provide a ptrdiff_t
alias. No functionality change.
Fix generation of obj-c @encoding for members with zero size.
Also follow gcc in that arrays of elements with zero size are encoded as arrays with zero elements.
Anders Carlsson [Sat, 14 May 2011 23:26:09 +0000 (23:26 +0000)]
When emitting the destructor for a class with a vtable, if we can determine
that the destructor body is trivial and that all member variables also have either
trivial destructors or trivial destructor bodies, we don't need to initialize the
vtable pointers since no virtual member functions will be called on the destructor.
John McCall [Sat, 14 May 2011 21:12:11 +0000 (21:12 +0000)]
Only perform the null-initialization of an aggregate result of a message
send if the receiver is null. Normally it's not worthwhile to check this,
but avoiding the null-initialization is nice, and this also avoids nasty
problems where the null-initialization is visible within the call because
we use an aliased result buffer. rdar://problem/9402992
Create proper Objective-C @encoding for C++ classes; fixes rdar://9357400.
Go through and expand the members of bases into the encoding string (and encode the VTable as well).
Unlike gcc which expands virtual bases as many times as they appear in the
hierarchy, clang will only expand them once at the end, to reflect the actual layout.
Note that there doesn't seem to be a way to indicate in the encoding that
packing/alignment of members is different that normal, in which case
the encoding will be out-of-sync with the real layout.
If the runtime switches to just consider the size of types without
taking into account alignment, we could easily make padding explicit in the
encoding (e.g. using arrays of chars). The encoding strings would be
longer then though.
Also encode a flexible array member as array of 0 size, like gcc, not as a pointer.
Emit an error when trying to @encode an incomplete type.
There are APIs, e.g. [NSValue valueWithBytes:objCType:], which use the encoding to find out
the size of an object pointed to by a pointer. Make things safer by making it illegal to @encode
incomplete types.
Richard Smith [Sat, 14 May 2011 15:04:18 +0000 (15:04 +0000)]
PR9908: Fix the broken fix for PR9902 to get the template argument lists in the right order.
Also, don't reject alias templates in all ElaboratedTypes: some ElaboratedTypes do not correspond to elaborated-type-specifiers.
John McCall [Sat, 14 May 2011 03:10:52 +0000 (03:10 +0000)]
Objective-C vtables are not taking the world by storm; call them
out as "v-table" message sends and stop calling normal messages "legacy"
message sends.
Also, fix some comments to reveal the true state of affairs.
__has_extension is a function-like macro which takes the same set
of feature identifiers as __has_feature. It evaluates to 1 if the
feature is supported by Clang in the current language (either as a
language extension or a standard language feature) or 0 if not.
At the same time, add support for the C1X feature identifiers
c_generic_selections (renamed from generic_selections) and
c_static_assert, and document them.
This introduces a generic base class for the expression evaluator
classes, which handles a few common expression types which were
previously handled separately in each class. Also, the expression
evaluator now uses ConstStmtVisitor.
ConstStmtVisitor is a constness-preserving variant of StmtVisitor.
ConstStmtVisitor and StmtVisitor share an implementation using a common
base class, StmtVisitorBase, which uses a template template parameter
to build pointer types.
Douglas Gregor [Fri, 13 May 2011 01:05:07 +0000 (01:05 +0000)]
When determining whether we can make a declaration into a global
constant, also consider whether it's a class type that has any mutable
fields. If so, it can't be a global constant.
Douglas Gregor [Fri, 13 May 2011 00:34:01 +0000 (00:34 +0000)]
Teach the template parameter dependency checker used when matching
template parameter lists to scope specifiers for friend declarations
about injected class name types. Fixes the
g++.dg/template/memfriend5.C regression in the GCC testsuite.