Commit Graph

767 Commits

Author SHA1 Message Date
Fariborz Jahanian 751f7bc03c Fixes a Code Gen. Crash when calling destructor on a __block
variabe. Blocks and their construction/destruction is
wip though. 

llvm-svn: 102985
2010-05-04 00:26:07 +00:00
John McCall 5828ee7a27 Just bail out immediately when emitting an unreachable function-local static
variable.  Surprisingly, this does seem to be the right way to solve this.

llvm-svn: 102961
2010-05-03 21:39:56 +00:00
Douglas Gregor aee1f51485 If we're generating code to create a pointer-to-member function
aggregate and the result of the aggregate is unused, bail out
early. Fixes PR7027.

llvm-svn: 102942
2010-05-03 20:00:27 +00:00
Anders Carlsson 3572d44190 When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
llvm-svn: 102921
2010-05-03 16:05:06 +00:00
Douglas Gregor df9ae794ca Try to unbreak clang-i686-darawin10 builder
llvm-svn: 102920
2010-05-03 15:51:04 +00:00
Anders Carlsson f93cb3bacb Get rid of virt.cpp.
llvm-svn: 102918
2010-05-03 15:49:15 +00:00
Douglas Gregor 456ad1a817 When a class contains a non-empty anonymous union or struct, mark is
as non-empty. Fixes PR7021.

llvm-svn: 102913
2010-05-03 15:18:25 +00:00
Anders Carlsson d040e6b25a Don't build an aggregate constructor loop when the constructor is trivial.
llvm-svn: 102912
2010-05-03 15:09:17 +00:00
Anders Carlsson 604f560c39 Add test case that I forgot to check in.
llvm-svn: 102905
2010-05-03 14:22:40 +00:00
Anders Carlsson 16e94af67c Don't copy or initialize empty classes. Fixes PR7012.
llvm-svn: 102891
2010-05-03 01:20:20 +00:00
Douglas Gregor b139cd5843 Complete reimplementation of the synthesis for implicitly-defined copy
assignment operators. 

Previously, Sema provided type-checking and template instantiation for
copy assignment operators, then CodeGen would synthesize the actual
body of the copy constructor. Unfortunately, the two were not in sync,
and CodeGen might pick a copy-assignment operator that is different
from what Sema chose, leading to strange failures, e.g., link-time
failures when CodeGen called a copy-assignment operator that was not
instantiation, run-time failures when copy-assignment operators were
overloaded for const/non-const references and the wrong one was
picked, and run-time failures when by-value copy-assignment operators
did not have their arguments properly copy-initialized.

This implementation synthesizes the implicitly-defined copy assignment
operator bodies in Sema, so that the resulting ASTs encode exactly
what CodeGen needs to do; there is no longer any special code in
CodeGen to synthesize copy-assignment operators. The synthesis of the
body is relatively simple, and we generate one of three different
kinds of copy statements for each base or member:

  - For a class subobject, call the appropriate copy-assignment
    operator, after overload resolution has determined what that is.
  - For an array of scalar types or an array of class types that have
    trivial copy assignment operators, construct a call to
    __builtin_memcpy.
  - For an array of class types with non-trivial copy assignment
    operators, synthesize a (possibly nested!) for loop whose inner
    statement calls the copy constructor.
  - For a scalar type, use built-in assignment.

This patch fixes at least a few tests cases in Boost.Spirit that were
failing because CodeGen picked the wrong copy-assignment operator
(leading to link-time failures), and I suspect a number of undiagnosed
problems will also go away with this change.

Some of the diagnostics we had previously have gotten worse with this
change, since we're going through generic code for our
type-checking. I will improve this in a subsequent patch.

llvm-svn: 102853
2010-05-01 20:49:11 +00:00
Chris Lattner 036078ca76 with recent optimizer changes, these all get devirtualized.
llvm-svn: 102825
2010-05-01 01:42:06 +00:00
John McCall b3cec96a7c Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases.  Just a patch until Sema starts (correctly) doing
most of this analysis.

Fixes PR 6622.

llvm-svn: 102692
2010-04-30 05:56:45 +00:00
John McCall 48bf349471 Fix -fno-rtti -fexceptions by forcing the emission of (non-"builtin") RTTI
when used by the exceptions routines.  Fixes PR 6974.

llvm-svn: 102684
2010-04-30 01:15:21 +00:00
Douglas Gregor 980fb16f9a When determining a standard conversion sequence involves resolving the
address of an overloaded function (or function template), perform that
resolution prior to determining the implicit conversion
sequence. This resolution is not part of the implicit conversion
sequence itself.

Previously, we would always consider this resolution to be a
function pointer decay, which was a lie: there might be an explicit &
in the expression, in which case decay should not occur. This caused
the CodeGen assertion in PR6973 (where we created a 
pointer to a pointer to a function when we should have had a pointer
to a function), but it's likely that there are corner cases of
overload resolution where this would have failed.

Cleaned up the code involved in determining the type that will
produced afer resolving the overloaded function reference, and added
an assertion to make sure the result is correct. Fixes PR6973.

llvm-svn: 102650
2010-04-29 18:24:40 +00:00
Douglas Gregor 7988def89f Improve name mangling for dependent template names (e.g., typename
T::template apply<U>), handling a few cases where we previously failed
and performing substitutions on such dependent names. Fixes a crash in
Boost.PropertyTree.

llvm-svn: 102490
2010-04-28 05:58:56 +00:00
Douglas Gregor 199db36b79 When explicitly building a temporary object (CXXTemporaryObjectExpr),
keep track of whether we need to zero-initialize storage prior to
calling its constructor. Previously, we were only tracking this when
implicitly constructing the object (a CXXConstructExpr).

Fixes Boost's value-initialization tests, which means that the
Boost.Config library now passes all of its tests.

llvm-svn: 102461
2010-04-27 20:36:09 +00:00
Chris Lattner 5e8416a77f emit dtors with the right calling convention in -fno-use-cxa-atexit
mode.

llvm-svn: 102377
2010-04-26 20:35:54 +00:00
Chris Lattner 954daf9aa5 remove alignment specifier on this. CAn't this test be removed yet? :)
llvm-svn: 102369
2010-04-26 19:47:56 +00:00
Douglas Gregor 9094fcb7c1 Tweak test for destruction of copied temporary objects
llvm-svn: 102291
2010-04-25 00:56:07 +00:00
Douglas Gregor d0ace02496 When copying a temporary object to initialize an entity for which the
temporary needs to be bound, bind the copy object. Otherwise, we won't
end up calling the destructor for the copy. Fixes Boost.Optional.

llvm-svn: 102290
2010-04-25 00:55:24 +00:00
Douglas Gregor 914af2182b Handle compound assignment expressions (i += j) as lvalues, which is
permitted in C++ but not in C. Fixes PR6900. Clang can now handle all
of Boost.Lambda's regression tests.

llvm-svn: 102170
2010-04-23 04:16:32 +00:00
Douglas Gregor 173627188d Mangle dependent template names such as the nested-name-specifier in
T::apply <U>::type

Fixes PR6899, although I want to dig a little deeper into the FIXME
for dependent template names that refer to operators.

llvm-svn: 102167
2010-04-23 03:10:43 +00:00
Douglas Gregor 19043f0a6a I hate default statements. Fixes PR6874.
llvm-svn: 102160
2010-04-23 02:02:43 +00:00
John McCall 69349f458b Neuter this testcase a little. The way LLVM writes labels for anonymous blocks
makes it impossible to check labels.

llvm-svn: 102048
2010-04-22 03:27:09 +00:00
John McCall 2e6567ae60 Call PerformCopyInitialization to properly initialize the exception temporary
in a throw expression.  Use EmitAnyExprToMem to emit the throw expression,
which magically elides the final copy-constructor call (which raises a new
strict-compliance bug, but baby steps).  Give __cxa_throw a destructor pointer
if the exception type has a non-trivial destructor.

llvm-svn: 102039
2010-04-22 01:10:34 +00:00
Devang Patel b9ab309650 Encode field accessibility.
llvm-svn: 102033
2010-04-21 23:12:37 +00:00
Fariborz Jahanian acdfa7acfe Fixes a code gen. bug by removing an assert.
It is ok to have c++-ness inside extern "C" 
block. Fixes pr6644.

llvm-svn: 101948
2010-04-20 22:02:31 +00:00
Anders Carlsson 91baecfeb3 Back out r101911 and see if it makes the bots happy.
llvm-svn: 101921
2010-04-20 18:05:10 +00:00
Anders Carlsson 6a0227df49 Fix a bug which triggered the assertion I added yesterday. Basically, when we initialize the vtable pointer for a virtual base, and there was another path from the most derived class to another base with the same class type, we would use the wrong base.
llvm-svn: 101911
2010-04-20 16:22:16 +00:00
Chris Lattner 9cffdf1331 don't slap noalias attribute on stret result arguments.
This mirror's Dan's patch for llvm-gcc in r97989, and
fixes the miscompilation in PR6525.  There is some contention
over whether this is the right thing to do, but it is the
conservative answer and demonstrably fixes a miscompilation.

llvm-svn: 101877
2010-04-20 05:44:43 +00:00
John McCall 0f55a035cf Restore r101841 without modification. Also mark 'operator delete' as used for
actual delete expressions, not just new expressions.

llvm-svn: 101861
2010-04-20 02:18:25 +00:00
Rafael Espindola 683fe4fc4c If a method is virtual and the class key function is in another file, emit the method as available_externally.
Fixes PR6747

llvm-svn: 101757
2010-04-19 00:44:22 +00:00
Fariborz Jahanian 3fef72f0ba Local static variables must be available module-wise
as they are accessible in static methods in a class
local to the same function. Fixes PR6769.

llvm-svn: 101756
2010-04-18 21:01:23 +00:00
Anders Carlsson d5f27b0583 Simplify wide bit-field layout in CGRecordLayoutBuilder, and also fix a bug where assigning to a bit-field member would overwrite other parts of the struct.
llvm-svn: 101681
2010-04-17 22:54:57 +00:00
Anders Carlsson 2295f13bb0 Unnamed bit-fields in a union should be laid out with a type that doesn't affect alignment.
llvm-svn: 101673
2010-04-17 21:04:52 +00:00
Anders Carlsson aad5fa85d0 If a wide bit-field is inside a union its offset should always be 0.
llvm-svn: 101668
2010-04-17 20:21:41 +00:00
Anders Carlsson c6db5ab8b2 Fix a bug where we would sometimes incorrectly mark an vtable function as unused.
llvm-svn: 101643
2010-04-17 17:24:33 +00:00
Ted Kremenek 1a596562ed Specify temporary file for -emit-llvm output in test case so that we don't deposit the file
in the original source directory.

llvm-svn: 101402
2010-04-15 21:11:33 +00:00
Anders Carlsson ea7b18298e Split adding the primary virtual base offsets out into a separate pass. This fixes a bug where we would lay out virtual bases in the wrong order.
llvm-svn: 101373
2010-04-15 16:12:58 +00:00
Fariborz Jahanian 9ffd706bd4 Add encoding of reference types like gcc does for objc methods and
blocks. Fixes PR6468.

llvm-svn: 101196
2010-04-13 23:45:47 +00:00
Devang Patel 74c10507a6 Fix debug info for cleanup block.
llvm-svn: 101100
2010-04-13 00:08:43 +00:00
Nick Lewycky 7ff88f8b00 Typo.
llvm-svn: 101015
2010-04-12 05:32:01 +00:00
Anders Carlsson 3383e2ad74 Fix another bug where we wouldn't generate secondary vtables for construction vtables in some cases.
llvm-svn: 100998
2010-04-11 22:20:36 +00:00
Anders Carlsson 343a26b56d Fix a bug where we were adding too many vcall offsets in some cases.
llvm-svn: 100985
2010-04-11 20:04:11 +00:00
Anders Carlsson 7a148f7141 Fix another vbase layout bug.
llvm-svn: 100952
2010-04-10 21:35:33 +00:00
Anders Carlsson 88cf34f2b4 Fix a bug where we would add the same function twice in a vtable.
llvm-svn: 100949
2010-04-10 20:39:29 +00:00
Anders Carlsson 291279e3a6 Simplify the virtual base layout code and fix a bug where we wouldn't store the offset for a virtual base.
llvm-svn: 100940
2010-04-10 18:42:27 +00:00
John McCall 09277542f2 Provide manglings for bool and character literal expressions. These are
just integer-literal expressions with special case implementations in the AST.

Fixes rdar://problem/7825453.

llvm-svn: 100905
2010-04-09 21:48:08 +00:00
John McCall 3155f573f5 Turn access control on by default in -cc1.
Remove -faccess-control from -cc1; add -fno-access-control.
Make the driver pass -fno-access-control by default.
Update a bunch of tests to be correct under access control.

llvm-svn: 100880
2010-04-09 19:03:51 +00:00