Douglas Gregor
363b151ff7
When transforming CXXExprWithTemporaries and CXXBindTemporaryExpr
...
expressions (e.g., for template instantiation), just transform the
subexpressions and return those, since the temporary-related nodes
will be implicitly regenerated. Fixes PR5867, but I said that
before...
llvm-svn: 92135
2009-12-24 18:51:59 +00:00
Douglas Gregor
f82bead3fd
InitializationSequence handles binding to temporaries, so that
...
argument-passing doesn't have to. Fixes PR5867, where we were binding
a temporary twice in the AST and, therefore, calling its destructor
twice.
llvm-svn: 92131
2009-12-24 17:16:46 +00:00
Anders Carlsson
a88d197284
Mangle block pointer types. Fixes PR5858.
...
llvm-svn: 92069
2009-12-23 22:31:44 +00:00
Douglas Gregor
247894b361
There is no such thing as typeinfo for a cv-qualified type. Assert
...
that this is true when mangling, then fix up the various places in
Sema and/or CodeGen that need to remove qualifiers. Addresses a
linking issue when building LLVM with Clang.
llvm-svn: 92064
2009-12-23 22:04:40 +00:00
Douglas Gregor
f45f6828c6
Remove cv-qualifiers from the argument to typeid
...
llvm-svn: 92041
2009-12-23 20:51:04 +00:00
Anders Carlsson
910847c149
Mangle template template parameters. Fixes PR5861.
...
llvm-svn: 92030
2009-12-23 19:30:55 +00:00
Douglas Gregor
19fc0b753a
Make sure that reinterpret_cast gets a CastKind on all successful
...
paths. Fixes "cannot compile this unexpected cast lvalue yet" error in
llvm/lib/Analysis/IPA/GlobalsModRef.cpp.
llvm-svn: 91932
2009-12-22 22:47:22 +00:00
Anders Carlsson
8a35c7982c
Make sure that we mangle overloaded operators that are member functions correctly, giving them the correct arity.
...
With this seemingly insignificant fix, we are now able to build and link clang using clang itself! (LLVM still has to be built with gcc for the time being).
llvm-svn: 91893
2009-12-22 06:36:32 +00:00
Daniel Dunbar
3780f0b680
x86_64: Structures with no fields but which have padding should be classified as
...
integer.
- This is consistent, but may not be correct. I will revisit x86_64 ABI handling for C++ as a whole at some point.
- PR5831.
llvm-svn: 91874
2009-12-22 01:19:25 +00:00
Douglas Gregor
4141d5bea2
When converting from a type to itself or one of its base classes via a
...
constructor call, the conversion is only a standard conversion
sequence if that constructor is a copy constructor. This fixes PR5834
in a semi-lame way, because the "real" fix will be to move over to
InitializationSequence. That will happen "soonish", but not now.
llvm-svn: 91861
2009-12-22 00:21:20 +00:00
Anders Carlsson
9a98ac993f
Add tests for structs inside anonymous namespaces.
...
llvm-svn: 91806
2009-12-21 00:57:38 +00:00
Anders Carlsson
2b7f444366
Incomplete structs should also have internal linkage.
...
llvm-svn: 91805
2009-12-21 00:41:42 +00:00
Anders Carlsson
18e6ee1b20
Correcly handle pointers to member pointer types where the class or the pointee is incomplete.
...
llvm-svn: 91804
2009-12-20 23:37:55 +00:00
Anders Carlsson
d008129f34
Rework the way pointer types are handled by the RTTI builder. We now get the right linkage for indirect pointers to incomplete structs.
...
llvm-svn: 91799
2009-12-20 22:30:54 +00:00
Douglas Gregor
a4b592a7d5
Switch more of Sema::CheckInitializerTypes over to
...
InitializationSequence. Specially, switch initialization of a C++
class type (either copy- or direct-initialization).
Also, make sure that we create an elidable copy-construction when
performing copy initialization of a C++ class variable. Fixes PR5826.
llvm-svn: 91750
2009-12-19 03:01:41 +00:00
Anders Carlsson
6fda43f4c1
Correctly initialize the PrimaryBaseInfo if a base is null. Fixes PR5832.
...
llvm-svn: 91748
2009-12-19 02:13:41 +00:00
Eli Friedman
357e8c94d6
Fix for PR5524: make reference binding in default argument work correctly.
...
llvm-svn: 91733
2009-12-19 00:20:10 +00:00
Eli Friedman
726b878574
Test for r91724.
...
llvm-svn: 91730
2009-12-18 23:42:55 +00:00
Anders Carlsson
0087bc851c
Fix regression I introduced when dynamic_cast-ing to a reference type.
...
llvm-svn: 91687
2009-12-18 14:55:04 +00:00
Anders Carlsson
b396f43520
It's perfectly fine to see UserDefinedConversion casts when emitting scalar expressions.
...
llvm-svn: 91686
2009-12-18 14:42:03 +00:00
Douglas Gregor
e1314a64b8
Switch the initialization required by return statements over to the
...
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:
- InitializationSequence now has a "C conversion sequence" category
and step kind, which falls back to
- Changed the diagnostics for returns to always have the result type
of the function first and the type of the expression second.
CheckSingleAssignmentConstraints to peform checking in C.
- Improved ASTs for initialization of return values. The ASTs now
capture all of the temporaries we need to create, but
intentionally do not bind the tempoary that is actually returned,
so that it won't get destroyed twice.
- Make sure to perform an (elidable!) copy of the class object that
is returned from a class.
- Fix copy elision in CodeGen to properly see through the
subexpressions that occur with elidable copies.
- Give "new" its own entity kind; as with return values and thrown
objects, we don't bind the expression so we don't call a
destructor for it.
Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.
llvm-svn: 91669
2009-12-18 05:02:21 +00:00
Sean Callanan
12ca3f46d8
Testcase fixes to reflect instruction table changes in the LLVM backend
...
(http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091214/092780.html )
The instruction fixes were checked and approved by Chris Lattner, but
these testcase fixes are mine; please yell at me if there are any
problems with either.
* PR5050-constructor-conversion.cpp
* array-construction.cpp
* constructor-conversion.cpp
* cast-conversion.cpp
* constructor-default-arg.cpp
* derived-to-base-conv.cpp
* ptr-to-member-function.cpp
* call-arg-zero-temp.cpp
* default-destructor-synthesis.cpp
* global-array-destruction.cpp
* array-operator-delete-call.cpp
* decl-ref-init.cpp
* default-constructor-for-members.cpp
* convert-to-fptr.cpp
* constructor-for-array-members.cpp
* conversion-function.cpp
* objc-read-weak-byref.m
Fixed testcase to reflect call qualifier
llvm-svn: 91640
2009-12-18 00:04:09 +00:00
Nuno Lopes
641fdce235
revert part of my last patch, and mark only the c++ global new operator as noalias. the rest will be infered by llvm optz
...
llvm-svn: 91600
2009-12-17 10:15:49 +00:00
Anders Carlsson
539e584c3c
Attempt to fix rtti-layout.cpp on Linux.
...
llvm-svn: 91581
2009-12-17 04:57:25 +00:00
Anders Carlsson
dc9b9cf7b1
Add a (currently failing) RTTI layout test.
...
llvm-svn: 91580
2009-12-17 04:41:05 +00:00
Douglas Gregor
8cdc2e0590
Fix test case to unbreak testing
...
llvm-svn: 91551
2009-12-16 19:18:40 +00:00
Douglas Gregor
4f4b186215
When value-initializing a class with no user-defined constructors but
...
with a non-trivial default constructor, zero-initialize the storage
and then call the default constructor. Fixes PR5800.
llvm-svn: 91548
2009-12-16 18:50:27 +00:00
Anders Carlsson
d681a29ac0
Baby steps towards fixing PR5589. If a class needs a vtable pointer, add one.
...
llvm-svn: 91545
2009-12-16 17:27:20 +00:00
Nuno Lopes
13c88c7269
implement PR5654: add -fassume-sane-operator-new, which is enabled by default, and adds the malloc attribute to the global function new() and to the overloaded new operators.
...
feel free to chage the name to this lengthy argument
llvm-svn: 91543
2009-12-16 16:59:22 +00:00
Anders Carlsson
07863b8b6e
Use GetAddrOfRTTI everywhere and remove GenerateRTTI and GenerateRTTIRef. With this change, we can now compile and link TableGen.
...
llvm-svn: 91520
2009-12-16 07:05:41 +00:00
Anders Carlsson
18ada9856f
Handle ImplicitValueInitExpr in AggExprEmitter.
...
llvm-svn: 91519
2009-12-16 06:57:54 +00:00
Anders Carlsson
b7e93e268f
Mangle CXXOperatorCallExprs, fixes PR5796.
...
llvm-svn: 91507
2009-12-16 05:48:46 +00:00
Daniel Dunbar
5618e98f33
Update tests to use %clang instead of 'clang', and forcibly disable use of '
...
clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to
garbage).
llvm-svn: 91460
2009-12-15 22:01:24 +00:00
Daniel Dunbar
8fbe78f6fc
Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
...
- This is designed to make it obvious that %clang_cc1 is a "test variable"
which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
can be useful to redefine what gets run as 'clang -cc1' (for example, to set
a default target).
llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Eli Friedman
2151725325
Fix a small bug in ComputeMethodVtableIndices.
...
llvm-svn: 91411
2009-12-15 03:31:17 +00:00
Eli Friedman
8d83842761
Really fix this test.
...
llvm-svn: 91409
2009-12-15 03:22:41 +00:00
Eli Friedman
a2761ba52f
Fix test broken by my last commit.
...
llvm-svn: 91396
2009-12-15 02:20:06 +00:00
Douglas Gregor
db121bad2a
When rebuilding CXXConstructExprs after a transformation, use
...
CompleteConstructorCall to perform type-checking.
llvm-svn: 91279
2009-12-14 16:27:04 +00:00
Anders Carlsson
e66e2942fc
Mangle unary, binary and ternary expressions correctly.
...
llvm-svn: 91257
2009-12-14 01:45:37 +00:00
Eli Friedman
b095e15af4
Fix for PR5714: make sure globals that will be modified aren't marked const.
...
llvm-svn: 91156
2009-12-11 21:23:03 +00:00
Eli Friedman
3ace52b3a7
Fix linkage of type info and vtable for classes without linkage.
...
llvm-svn: 91152
2009-12-11 20:48:18 +00:00
Eli Friedman
75c9b97123
Make sure mangling doesn't crash in another case. Add some more tests.
...
llvm-svn: 91149
2009-12-11 20:21:38 +00:00
Eli Friedman
30e94d047e
Fix for PR5706: let mangleName deal with mangling names without identifiers
...
correctly.
llvm-svn: 91136
2009-12-11 18:00:57 +00:00
Anders Carlsson
b41a5c9308
XFAIL this for now, fixing linkage bugs causes the order of globals to change. Will fix later today.
...
llvm-svn: 91130
2009-12-11 17:01:29 +00:00
Anders Carlsson
a0b98f083a
Use GetAddrOfRTTI when getting the RTTI pointer for a base class.
...
llvm-svn: 91127
2009-12-11 16:37:06 +00:00
Eli Friedman
68396b16f6
Move the code for converting a member pointer to a bool so that it is usable
...
for logical not.
llvm-svn: 91112
2009-12-11 09:26:29 +00:00
Eli Friedman
1762cf2ad0
Fix for PR5718: implement equality comparisons for member function pointers.
...
llvm-svn: 91108
2009-12-11 07:36:43 +00:00
Anders Carlsson
fd7dfeb779
Improve linkage of RTTI data structures. Introduce CodeGenModule::GetAddrOfRTTI which figures out the right linkage of the RTTI information for the given type and whether it should be defined or not. I will migrate clients over to GetAddrOfRTTI in subsequent commits (with tests).
...
llvm-svn: 91098
2009-12-11 02:46:30 +00:00
Eli Friedman
ad6c2e5b3a
Fix a recent regression from the initialization changes.
...
llvm-svn: 91097
2009-12-11 02:42:07 +00:00
Anders Carlsson
afd1edb52e
When an exception needs to be freed by calling __cxa_exception_free, make sure to stash away the exception pointer somewhere.
...
This fixes an "Instruction does not dominate all uses!" verification error when compiling TableGen.
llvm-svn: 91084
2009-12-11 00:32:37 +00:00
Eli Friedman
d70bbfd7d8
Support unary type traits in a scalar context. Not that I've actually seen
...
this construct, but might as well for completeness.
llvm-svn: 91071
2009-12-10 22:40:32 +00:00
Eli Friedman
ee275c82ff
Clean up enum constants so that they're finally sane. Fixes PR3173 and a
...
recently introduced crash.
llvm-svn: 91070
2009-12-10 22:29:29 +00:00
Anders Carlsson
781161dc55
Make sure that explicitly instantiated functions get the right linkage.
...
llvm-svn: 91069
2009-12-10 22:25:34 +00:00
Eli Friedman
d011893e86
Test for r90950.
...
llvm-svn: 91043
2009-12-10 08:51:23 +00:00
Anders Carlsson
a72ddd4609
Handle emitting static variables that have reference type.
...
llvm-svn: 91027
2009-12-10 01:05:11 +00:00
Mike Stump
25b20fc2ae
Add terminate handler for copy constructors for thrown objects. WIP.
...
llvm-svn: 90994
2009-12-09 23:31:35 +00:00
Douglas Gregor
3e1e527826
Reimplement reference initialization (C++ [dcl.init.ref]) using the
...
new notion of an "initialization sequence", which encapsulates the
computation of the initialization sequence along with diagnostic
information and the capability to turn the computed sequence into an
expression. At present, I've only switched one CheckReferenceInit
callers over to this new mechanism; more will follow.
Aside from (hopefully) being much more true to the standard, the
diagnostics provided by this reference-initialization code are a bit
better than before. Some examples:
p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct
Derived'
cannot bind to a value of unrelated type 'struct Base'
Derived &dr2 = b; // expected-error{{non-const lvalue reference to
...
^ ~
p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to
a value of
type 'struct Base const' drops qualifiers
Base &br3 = bc; // expected-error{{drops qualifiers}}
^ ~~
p5-var.cpp:57:15: error: ambiguous conversion from derived class
'struct Diamond' to base class 'struct Base':
struct Diamond -> struct Derived -> struct Base
struct Diamond -> struct Derived2 -> struct Base
Base &br5 = diamond; // expected-error{{ambiguous conversion from
...
^~~~~~~
p5-var.cpp:59:9: error: non-const lvalue reference to type 'long'
cannot bind to
a value of unrelated type 'int'
long &lr = i; // expected-error{{non-const lvalue reference to type
...
^ ~
p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct
Base' cannot
bind to a temporary of type 'struct Base'
Base &br1 = Base(); // expected-error{{non-const lvalue reference to
...
^ ~~~~~~
p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field
'i'
int & ir1 = (ib.i); // expected-error{{non-const reference cannot
...
^ ~~~~~~
p5-var.cpp:98:7: note: bit-field is declared here
int i : 17; // expected-note{{bit-field is declared here}}
^
llvm-svn: 90992
2009-12-09 23:02:17 +00:00
Eli Friedman
bb5008a32a
Fix for PR5707: make sure implicit copy constructors initialize the vtable
...
pointer.
llvm-svn: 90840
2009-12-08 06:46:18 +00:00
Eli Friedman
7316819fcf
Fix for PR5710: make sure to put function template specializations into the
...
DeclContext, so they don't completely disappear from the AST.
I don't particularly like this fix, but I don't see any obviously better way
to deal with it, and I think it's pretty clearly an improvement; comments
welcome.
llvm-svn: 90835
2009-12-08 05:40:03 +00:00
Eli Friedman
48c6b0d14f
Slight tweak to vtable linkage.
...
llvm-svn: 90832
2009-12-08 04:09:14 +00:00
Eli Friedman
f2c79b6b9c
Misc key function fixes.
...
llvm-svn: 90831
2009-12-08 03:56:49 +00:00
Eli Friedman
8aaff69e86
Fix some direct checks of expressions which might be surrounded by parentheses.
...
llvm-svn: 90825
2009-12-08 02:09:46 +00:00
Eli Friedman
cd6a50f3e5
Make copy assignment operator synthesis not explode for classes with complex
...
or non-record aggregate members.
It might be worth spending some time to optimize this code (and the parallel
code for copy constructors) to memcpy in larger chunks, rather than copying
one member at a time. Not sure exactly how beneficial that would be, but
it seems like could help for large classes with, for example, a vtable pointer
forcing the generation of a copy constructor.
llvm-svn: 90823
2009-12-08 01:57:53 +00:00
Anders Carlsson
220bf4fc5a
No need to add tail padding if the resulting LLVM struct type will have the same size as the final record size.
...
llvm-svn: 90820
2009-12-08 01:24:23 +00:00
Eli Friedman
f6c175b745
Correctly handle conditional operators involving throw.
...
llvm-svn: 90800
2009-12-07 20:25:53 +00:00
Anders Carlsson
1aaecfa02d
Mangle basic_ostream and basic_iostream specializations.
...
llvm-svn: 90794
2009-12-07 19:56:42 +00:00
Anders Carlsson
e1b3e6292a
It's OK to try to emit a vtable definition more than once. Fixes PR5697.
...
llvm-svn: 90751
2009-12-07 07:59:52 +00:00
Eli Friedman
d0e8de2cd8
Move RequireCompleteType requirement for fields early into ActOnField so that
...
subsequent code which depends on a complete type does the right thing.
llvm-svn: 90727
2009-12-07 00:22:08 +00:00
Sam Weinig
d060ed4d70
Don't print a void return type for C++ constructors and destructors when generating a predefined expr for them.
...
llvm-svn: 90725
2009-12-06 23:55:13 +00:00
Eli Friedman
8174f2c23c
Work-in-progess rewrite of thunks: move thunk generation outside of vtable
...
generation, and make sure we generate thunks when the function is defined
rather than when the vtable is defined.
llvm-svn: 90722
2009-12-06 22:01:30 +00:00
Anders Carlsson
3efc6e6f46
Add rudimentary support for member pointers to CGDebugInfo.
...
llvm-svn: 90711
2009-12-06 18:00:51 +00:00
Eli Friedman
eddf1213e2
Fix a slight oversight in computing whether a copy constructor is elidable.
...
Fixes PR5695.
llvm-svn: 90702
2009-12-06 09:26:33 +00:00
Anders Carlsson
232324c5c0
More linkage improvements.
...
llvm-svn: 90687
2009-12-06 00:53:22 +00:00
Anders Carlsson
0ab79e22ab
If a class does not have a key function, its linkage should be weak_odr.
...
llvm-svn: 90680
2009-12-05 22:24:38 +00:00
Anders Carlsson
58b271d450
Use createGlobalVariable for creating vtable variables too.
...
llvm-svn: 90679
2009-12-05 22:19:10 +00:00
Anders Carlsson
21bbc1e705
Factor vtable related GlobalVariable creation out into a separate function. Add vtable linkage test.
...
llvm-svn: 90667
2009-12-05 17:04:47 +00:00
Eli Friedman
0846d52f70
Tweak "key function" rules so that they work for templates with virtual
...
inline functions.
llvm-svn: 90645
2009-12-05 04:55:55 +00:00
Anders Carlsson
a30e1750cd
Don't emit explicit specializations of static member variable declarations.
...
llvm-svn: 90624
2009-12-04 23:50:01 +00:00
Anders Carlsson
cfb65d7432
Be a little more clever about inline member functions that are marked inline in the inline class declaration but not in the actual definition:
...
class A {
inline void f();
}
void A::f() { }
This is not the most ideal solution, since it doesn't work 100% with regular functions (as my FIXME comment states).
llvm-svn: 90607
2009-12-04 22:35:50 +00:00
Anders Carlsson
1f78b2bf62
Diagnose declarations of implicit member functions.
...
llvm-svn: 90605
2009-12-04 22:33:25 +00:00
Anders Carlsson
ce460529c0
When generating a virtual destructor, don't try to make a virtual call to the base class destructor because then we'll just re-enter the same destructor!
...
This was done to fix PR5619, so I went ahead and passed a dummy VTT pointer for now.
llvm-svn: 90578
2009-12-04 19:33:17 +00:00
Anders Carlsson
5c9e7b16a5
Correctly mangle the 'std' namespace inside extern "C++" blocks.
...
llvm-svn: 90544
2009-12-04 06:23:23 +00:00
Eli Friedman
d67751766b
Test for non-canonical decl and vtables.
...
llvm-svn: 90541
2009-12-04 04:30:55 +00:00
Eli Friedman
1d6fb1669c
Add recursion guards to ice-checking and evaluation for declrefs, so we
...
don't infinitely recurse for cases we can't evaluate.
llvm-svn: 90480
2009-12-03 20:31:57 +00:00
Anders Carlsson
ce2cd01647
Handle static_assert inside functions.
...
llvm-svn: 90461
2009-12-03 17:26:31 +00:00
Benjamin Kramer
70e39fe99c
Make test 64 bit safe.
...
llvm-svn: 90452
2009-12-03 13:09:24 +00:00
Eli Friedman
c339081c24
Fix for PR5659: correct a rather nasty oversight in the type conversion for
...
member pointer types.
llvm-svn: 90450
2009-12-03 12:44:31 +00:00
Eli Friedman
4039f35344
Fix thunk generation for thunks with a parameter with reference type.
...
llvm-svn: 90412
2009-12-03 04:49:52 +00:00
Eli Friedman
d4df7753d2
Fix for PR5522 and PR5666: fix a bunch of mangling issues with extern variables
...
and funcctions declared locally within a function.
llvm-svn: 90344
2009-12-02 20:32:49 +00:00
Eli Friedman
6393aac45e
Fix another "operator delete missing" crash: make sure we don't check
...
isVirtual() before we've actually calculated whether the destructor is
virtual.
llvm-svn: 90303
2009-12-02 07:16:50 +00:00
Eli Friedman
df76fe45e6
Tweak test to check for a bit more.
...
llvm-svn: 90302
2009-12-02 07:04:32 +00:00
Eli Friedman
81bce6b05e
Make sure to call AddOverriddenMethods for implicit copy assignment operators;
...
it's rare, but possible, for the difference to be significant.
llvm-svn: 90301
2009-12-02 06:59:20 +00:00
Fariborz Jahanian
4d9ab43f23
Fix a code gen. crash synthesizing a destructor.
...
Fixes pr5660.
llvm-svn: 90283
2009-12-01 23:18:25 +00:00
Fariborz Jahanian
b0cd26ad21
Test for my last patch.
...
llvm-svn: 90159
2009-11-30 22:07:56 +00:00
Daniel Dunbar
441e3729a5
Add missing assignment operator to test, and add tests for while loops and for
...
loops (including temporaries inside the initializers).
llvm-svn: 90151
2009-11-30 20:00:35 +00:00
Daniel Dunbar
7bd1048f26
Add more sophisticated test for destruction order of C++ temporaries, please
...
feel free to extend!
llvm-svn: 90143
2009-11-30 18:17:34 +00:00
Eli Friedman
78910a508a
Add a much more thorough test of casts to virtual bases, and fix
...
GetCXXBaseClassOffset to actually pass the test.
llvm-svn: 90025
2009-11-28 03:31:34 +00:00
Eli Friedman
2adc9abd51
Some member pointer casting tests.
...
llvm-svn: 89989
2009-11-27 04:56:40 +00:00
Eli Friedman
250534cf9a
Fix for PR5594: use EmitGlobalDefinition instead of EmitCXXDestructor so that
...
we check whether the vtable needs to be generated.
llvm-svn: 89984
2009-11-27 01:42:12 +00:00
Eli Friedman
84a7e347bf
Simplify and fix up the handling of implicit constructors, copy assignment
...
operators, and destructors. Avoids generating declarations/definitions of
trivial constructors/destructors, and makes sure the trivial copy assignment
operator is generated when necessary.
llvm-svn: 89943
2009-11-26 07:40:08 +00:00
Eli Friedman
d15eb34d4b
Implement IRGen for MemberExpr referring to static member function.
...
llvm-svn: 89938
2009-11-26 06:08:14 +00:00
Eli Friedman
f873c2fb68
Slight tweak to the algorithm for getLinkage().
...
llvm-svn: 89932
2009-11-26 03:04:01 +00:00
Eli Friedman
8a5f75ed5d
Use new getLinkage() method to correctly compute whether a variable has
...
internal linkage. Fixes PR5433.
llvm-svn: 89931
2009-11-26 02:52:12 +00:00
Anders Carlsson
82ba57c8f0
Add VTT parameter to base ctors/dtors with virtual bases. (They aren't used yet).
...
llvm-svn: 89835
2009-11-25 03:15:49 +00:00
Douglas Gregor
3d9e90ae3e
Implement proper cleanup semantics for condition variables in for
...
statements, e.g.,
for(; X x = X(); ) { ... }
Daniel or Anders, please review!
llvm-svn: 89832
2009-11-25 01:51:31 +00:00
Douglas Gregor
e05b765b0d
Tweak the code-generation-for-condition-variables test case to get to what we want to test
...
llvm-svn: 89818
2009-11-25 00:29:29 +00:00
Douglas Gregor
7bab5ff8e7
Eliminate CXXConditionDeclExpr with extreme prejudice.
...
All statements that involve conditions can now hold on to a separate
condition declaration (a VarDecl), and will use a DeclRefExpr
referring to that VarDecl for the condition expression. ForStmts now
have such a VarDecl (I'd missed those in previous commits).
Also, since this change reworks the Action interface for
if/while/switch/for, use FullExprArg for the full expressions in those
expressions, to ensure that we're emitting
Note that we are (still) not generating the right cleanups for
condition variables in for statements. That will be a follow-on
commit.
llvm-svn: 89817
2009-11-25 00:27:52 +00:00
Douglas Gregor
680f861d74
Clean up the AST for while loops and fix several problems with
...
cleanups for while loops:
1) Make sure that we destroy the condition variable of a while statement each time through the loop for, e.g.,
while (shared_ptr<WorkInt> p = getWorkItem()) {
// ...
}
2) Make sure that we always enter a new cleanup scope for the body of the while loop, even when there is no compound expression, e.g.,
while (blah)
RAIIObject raii(blah+1);
llvm-svn: 89800
2009-11-24 21:15:44 +00:00
Anders Carlsson
3c9beab48a
Handle references correctly when synthesizing copy constructors.
...
With this change, the clang-on-clang test result is now
Expected Passes : 224
Unexpected Failures: 37
Which means that we can compile over 80% of clang with clang! :)
llvm-svn: 89799
2009-11-24 21:08:10 +00:00
Fariborz Jahanian
831451b417
Fix the test case failed in buildbot.
...
llvm-svn: 89791
2009-11-24 19:37:10 +00:00
Anders Carlsson
3a202f601e
Handle cases where we're constructing an array of objects and the constructor has default arguments.
...
llvm-svn: 89783
2009-11-24 18:43:52 +00:00
Fariborz Jahanian
835026e9f1
Refactor collection of call arguments in common code.
...
Add support for variadic collection functions. More to do
here.
llvm-svn: 89781
2009-11-24 18:29:37 +00:00
Douglas Gregor
dcf1962405
Explicitly store the condition variable within switch statements, and
...
make sure that this variable is destroyed when we exit the switch
statement.
llvm-svn: 89776
2009-11-24 17:07:59 +00:00
Anders Carlsson
b9f96a3286
We always need to emit the base expression of a member expression, even when the member decl refers to an enum. Thanks to Eli for pointing this out!
...
llvm-svn: 89775
2009-11-24 16:57:33 +00:00
Anders Carlsson
b7408b95ed
Fix a crash when "instantiating" VarDecls that are neither type nor value dependent.
...
llvm-svn: 89774
2009-11-24 16:52:50 +00:00
Douglas Gregor
965f450d42
Introduce cleanup scopes for "if" statements in two places:
...
- Outside the "if", to ensure that we destroy the condition variable
at the end of the "if" statement rather than at the end of the
block containing the "if" statement.
- Inside the "then" and "else" branches, so that we emit then- or
else-local cleanups at the end of the corresponding block when the
block is not a compound statement.
To make adding these new cleanup scopes easier (and since
switch/do/while will all need the same treatment), added the
CleanupScope RAII object to introduce a new cleanup scope and make
sure it gets cleaned up.
llvm-svn: 89773
2009-11-24 16:43:22 +00:00
Anders Carlsson
bd97548f35
When mangling a ctor/dtor we need to take into consideration whether it's a member template.
...
llvm-svn: 89741
2009-11-24 05:36:32 +00:00
Anders Carlsson
0ade9715f2
Ignore constructor member templates in CodeGenModule::EmitTopLevelDecl.
...
llvm-svn: 89737
2009-11-24 05:16:24 +00:00
Anders Carlsson
6445773279
It is common for vtables to contain pointers to functions that have either incomplete return types or incomplete argument types.
...
Handle this by returning the llvm::OpaqueType for those cases, which CodeGenModule::GetOrCreateLLVMFunction knows about, and treats as being an "incomplete function".
llvm-svn: 89736
2009-11-24 05:08:52 +00:00
Anders Carlsson
f2e4f72f03
Don't try to treat an enum constant as an lvalue.
...
llvm-svn: 89705
2009-11-23 21:56:41 +00:00
Anders Carlsson
2e7bc11f11
Convert the && and || operands to bool using standard conversions. Fixes PR5593.
...
llvm-svn: 89704
2009-11-23 21:47:44 +00:00
Anders Carlsson
7fa434c2b8
Handle converting member pointers to bool.
...
llvm-svn: 89692
2009-11-23 20:04:44 +00:00
Sebastian Redl
22e2e5c423
Intercept sizeof and alignof references before they get into ASTContext methods. This fixes a crash when writing sizeof(Incomplete&), and lets ASTContext's methods do the right thing for CodeGen, which fixes PR5590.
...
llvm-svn: 89668
2009-11-23 17:18:46 +00:00
Daniel Dunbar
e1cd0152a9
x86_64, PR5582: Layout bases for C++ records.
...
- Ideally we would have an single iteration interface for this, but this works
for now.
llvm-svn: 89632
2009-11-22 23:01:23 +00:00
Anders Carlsson
5838108317
Use EmitStoreOfScalar when copying the scalar to the space allocated by 'new'.
...
llvm-svn: 89613
2009-11-22 19:25:33 +00:00
Anders Carlsson
e18e29eeb9
Support emitting aggregate class initializers. Fixes PR5581.
...
llvm-svn: 89569
2009-11-21 23:56:04 +00:00
Daniel Dunbar
88ad4c5d02
Mangler: Sketch mangling for TemplateArgument::Declaration kind.
...
- Several important FIXMEs related to whether arguments are expressions or external names, and the mangling of extern "C" names (c.f., PR5522).
llvm-svn: 89556
2009-11-21 09:17:15 +00:00
Mike Stump
4d119e49f9
Add testcases for recent checkins.
...
llvm-svn: 89469
2009-11-20 18:51:28 +00:00
Anders Carlsson
0a66c26191
Fix lifetime of conditional temporaries. Patch by Victor Zverovich!
...
llvm-svn: 89467
2009-11-20 17:27:56 +00:00
Mike Stump
a7a1b7e780
Fixup key function calculations.
...
llvm-svn: 89412
2009-11-20 00:02:19 +00:00
Fariborz Jahanian
1eab66c7cc
Patch to implement new-operators with default args.
...
Fixes pr5547.
llvm-svn: 89370
2009-11-19 18:39:40 +00:00
Mike Stump
c5d2ed73ff
Be sure to set visibility for ZTI symbols for classes from the class.
...
llvm-svn: 89186
2009-11-18 03:21:29 +00:00
Mike Stump
f77aaa0089
Make _ZTI symbols hidden. This speeds up the dynamic linker.
...
llvm-svn: 89185
2009-11-18 02:53:28 +00:00
Mike Stump
5bbbb13765
Fix one last gotcha with typeid.
...
llvm-svn: 89172
2009-11-18 00:40:12 +00:00
Mike Stump
103a084cbe
Add rtti support for arrays, functiond without prototypes, vectors and
...
enums.
llvm-svn: 89165
2009-11-17 23:45:57 +00:00
Mike Stump
96b96d5f2e
Add rtti info for function prototypes and refactor. This allows
...
pointer to member functions to work. WIP.
llvm-svn: 89161
2009-11-17 23:11:22 +00:00
Mike Stump
6fdfea67ad
Add rtti support for pointer to data members.
...
llvm-svn: 89155
2009-11-17 22:33:00 +00:00
Mike Stump
db72c89eb1
Add rtti support for non-member pointers. WIP.
...
llvm-svn: 89148
2009-11-17 21:44:24 +00:00
Jakob Stoklund Olesen
061644a69d
Undo previous test fix. -split-phi-edges now disables automatically when the
...
local register allocator is used.
llvm-svn: 89127
2009-11-17 19:18:32 +00:00
Anders Carlsson
dee9a30204
Unify the way destructor epilogues are generated for synthesized and regular destructors. Also fix PR5529.
...
llvm-svn: 89034
2009-11-17 04:44:12 +00:00
Mike Stump
8f5e6770e7
Add typeinfo support for T* and const T* for all builtin types T.
...
llvm-svn: 89030
2009-11-17 02:57:13 +00:00
Mike Stump
3f75d552a3
Add typeid for the builtin types. WIP.
...
llvm-svn: 89028
2009-11-17 02:16:21 +00:00
Jakob Stoklund Olesen
4359796e52
Fix tests after enabling -split-phi-edges.
...
object-size.c aws simply too fragile.
constructor-default-arg.cpp triggers an issue when LiveVariables is run before RALocal.
llvm-svn: 89025
2009-11-17 01:47:01 +00:00
Mike Stump
c2c03349f3
Ensure we peer through () when handling typeid(*p).
...
llvm-svn: 89015
2009-11-17 00:45:21 +00:00
Mike Stump
8a5acf1440
Note why this doesn't yet work.
...
llvm-svn: 89012
2009-11-17 00:30:31 +00:00
Mike Stump
61232fd252
Trim spacing.
...
llvm-svn: 89006
2009-11-17 00:14:04 +00:00
Eli Friedman
e85ef718d5
Fix up EmitMemberInitializer to handle many more cases.
...
llvm-svn: 88999
2009-11-16 23:53:01 +00:00
Mike Stump
82a1e6184a
Testcase for dynamic_cast.
...
llvm-svn: 88996
2009-11-16 23:36:30 +00:00
Eli Friedman
c1daba3ec8
Make member initializers for union members work correctly.
...
llvm-svn: 88989
2009-11-16 22:58:01 +00:00
Eli Friedman
c2ef215bda
Implement a few more cases for copy constructor synthesis.
...
llvm-svn: 88971
2009-11-16 21:47:41 +00:00
Mike Stump
4cdedd9d44
Fix members to be public.
...
llvm-svn: 88944
2009-11-16 19:48:50 +00:00
Mike Stump
3d47c2b3c2
Make bots happy.
...
llvm-svn: 88941
2009-11-16 19:34:15 +00:00
Mike Stump
6fa768df29
Fix spelling for target triplet.
...
llvm-svn: 88928
2009-11-16 18:06:39 +00:00
Mike Stump
266ee4a5b3
Try and fix buildbot issue.
...
llvm-svn: 88900
2009-11-16 06:49:10 +00:00
Eli Friedman
e6ce354795
Fix a couple of cases where we weren't generating the right kind of call
...
for a call to a virtual function.
llvm-svn: 88891
2009-11-16 05:31:29 +00:00
Eli Friedman
011c4c341b
Implement two-argument form of delete operator.
...
llvm-svn: 88890
2009-11-16 05:16:40 +00:00
Mike Stump
a46efbb857
Fix linux buildbots.
...
llvm-svn: 88856
2009-11-15 17:57:00 +00:00
Mike Stump
1bf924b121
Finish off zero check for typeid(*p) so that it will do a __cxa_bad_typeid.
...
llvm-svn: 88852
2009-11-15 16:52:53 +00:00
Mike Stump
c9b231c8d1
Implement typeid for class types.
...
llvm-svn: 88843
2009-11-15 08:09:41 +00:00
Mike Stump
4c808dfc58
Finish off support for typeinfo generation for classes.
...
llvm-svn: 88828
2009-11-15 03:28:10 +00:00
Anders Carlsson
50cb321fdc
Handle CK_BitCast in EmitCastLValue.
...
llvm-svn: 88810
2009-11-14 21:21:42 +00:00
Anders Carlsson
0acee6e0d7
Canonicalize the type before trying to create a debug type.
...
llvm-svn: 88808
2009-11-14 21:08:12 +00:00
Eli Friedman
274ab904d0
Avoid assert-crash in a case where the expression passed to EmitConstantExpr
...
legitimately has side-effects (and needs to be generated as a non-constant).
llvm-svn: 88767
2009-11-14 08:51:33 +00:00
Eli Friedman
b774685c08
Fix a couple of tests.
...
llvm-svn: 88756
2009-11-14 04:23:25 +00:00
Eli Friedman
b572c92674
PR5483: Generate missing form of destructor when it is virtual. (Someone
...
more familiar with this stuff should double-check that there isn't some more
general rule; this is purely from inspecting g++ output.)
llvm-svn: 88755
2009-11-14 04:19:37 +00:00
Eli Friedman
c9827d1ad3
Fix for PR5489: don't skip the complete type requrirement for variable
...
definitions just because the type happens to be an array type.
llvm-svn: 88752
2009-11-14 03:40:14 +00:00
Anders Carlsson
52ce3bbf57
Handle CXXDefaultArgExprs in EmitLValue. Fixes PR5484.
...
llvm-svn: 88735
2009-11-14 01:51:50 +00:00
Fariborz Jahanian
ebea005812
Code gen. For virtual destructor call on array objects
...
(still part of pr5472).
llvm-svn: 88712
2009-11-13 22:29:45 +00:00
Mike Stump
2fb78c0250
More VTT and constructor vtable testcases from recent work.
...
llvm-svn: 88710
2009-11-13 22:12:05 +00:00
Mike Stump
3693652378
Add more testcase for construction vtables and VTTs.
...
llvm-svn: 88702
2009-11-13 21:55:26 +00:00
Mike Stump
464de23b72
Add some more VTT testcases.
...
llvm-svn: 88699
2009-11-13 21:40:38 +00:00
Mike Stump
e56213fc1e
Add a testcase for the recent VTT work.
...
llvm-svn: 88681
2009-11-13 19:36:46 +00:00
Fariborz Jahanian
6814eaa2cc
Code gen for arrady delete operator. Fixes pr5472.
...
llvm-svn: 88680
2009-11-13 19:27:47 +00:00
Mike Stump
88fc7d4202
This falls into the category of stupid pet tricks. I hate to do this,
...
but this is necessary to continue work on virtual vtables. We don't
want to penalize virtual table building testcases, just because
complex virtual conversions don't yet work.
llvm-svn: 88676
2009-11-13 18:53:35 +00:00
Anders Carlsson
97df0b40c3
Don't bind arguments to temporaries if the argument has a reference type.
...
llvm-svn: 88662
2009-11-13 17:04:35 +00:00
Anders Carlsson
78cfaa9e56
Fix two bugs with temporaries:
...
1. For
A f() {
return A();
}
we were incorrectly calling the A destructor on the returned object.
2. For
void f(A);
void g() {
A a;
f(a);
}
we were incorrectly not calling the copy constructor.
llvm-svn: 87082
2009-11-13 04:34:45 +00:00
Daniel Dunbar
d8ff51bf49
Fix test portability.
...
llvm-svn: 86911
2009-11-12 00:41:41 +00:00
Fariborz Jahanian
d708eb6b6a
Make test more platform independent.
...
llvm-svn: 86890
2009-11-11 22:49:09 +00:00
Fariborz Jahanian
03f62ed9bb
Value initialize non-class array members in ctor's
...
initializer list. Fixes PR5463.
llvm-svn: 86849
2009-11-11 17:55:25 +00:00
Daniel Dunbar
568e302a7f
Fix some tests in -Asserts mode.
...
- FileCheck is a *huuuuge* improvement here.
- Still feels like we could use a better tool for this though, either teach
llvm-dis to spit out the FileCheck syntax, or provide another tool to turn a
.ll into a "matchable" input.
- Also on my Christmas list is better FileCheck diagnostics with missing
variables or mismatches.
llvm-svn: 86800
2009-11-11 03:48:26 +00:00
Fariborz Jahanian
4e088941ad
Diagnose illegally typed operator new/new[].
...
llvm-svn: 86755
2009-11-10 23:47:18 +00:00
Eli Friedman
3ad2645430
Fix for PR5454: make sure to use the right block as the predecessor in the
...
generated PHI node for the null check of a new operator.
llvm-svn: 86738
2009-11-10 22:39:09 +00:00
Fariborz Jahanian
1254a0978c
This patch implements Code gen. for destruction of
...
global array of objects.
llvm-svn: 86701
2009-11-10 19:24:06 +00:00
Eli Friedman
56acd1e819
Add code generation test for r86500.
...
llvm-svn: 86574
2009-11-09 18:49:09 +00:00
Eli Friedman
cb29876839
Add hack to make the given testcase work. As far as I can tell, this change is
...
reasonably safe, but it doesn't seem like the right solution.
llvm-svn: 86508
2009-11-09 03:59:26 +00:00
Eli Friedman
d7686ef31c
Unify the codepaths used to verify base and member initializers for explicitly
...
and implicitly defined constructors. This has a number of benefits:
1. Less code.
2. Explicit and implicit constructors get the same diagnostics.
3. The AST explicitly contains constructor calls from implicit default
constructors. This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.
llvm-svn: 86500
2009-11-09 01:05:47 +00:00
Daniel Dunbar
34546ce43d
Remove RUN: true lines.
...
llvm-svn: 86432
2009-11-08 01:47:25 +00:00
Daniel Dunbar
8b57697954
Eliminate &&s in tests.
...
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.
llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Anders Carlsson
5bbdc9f857
Handle member expressions where the member declaration is actually a static variable. Fixes PR5392.
...
llvm-svn: 86414
2009-11-07 23:16:50 +00:00
Anders Carlsson
c0a3561f0f
Always mangle functions with special names. Fixes PR5420.
...
llvm-svn: 86350
2009-11-07 07:15:03 +00:00
Anders Carlsson
ce21431fc4
When looking up and adding substitutions to the substitution table, make sure to always use the canonical declaration. With tihs change, FileCheck compiles and links but crashes during startup.
...
llvm-svn: 86339
2009-11-07 04:26:04 +00:00
Eli Friedman
01cad4c6b0
Make sure isCopyAssignment is only true for actual copy assignment operators,
...
instead of all assignment operators. The mistake messes up IRGen because
it ends up assuming that the assignment operator is actually the implicit
copy assignment operator, and therefore tries to emit the RHS as an lvalue.
llvm-svn: 86307
2009-11-07 00:02:45 +00:00
Mike Stump
cd6f9ed906
Refine the non-virtual this adjustment. Optimize out virtual this
...
adjustments of zero.
llvm-svn: 86300
2009-11-06 23:27:42 +00:00
Fariborz Jahanian
e8e631c912
Prevent a code gen. crash on empty unions - pr5408.
...
llvm-svn: 86287
2009-11-06 20:47:40 +00:00
Anders Carlsson
443f677302
Simplify the debug info code, handle lvalue references and template specializations.
...
llvm-svn: 86277
2009-11-06 19:19:55 +00:00
Fariborz Jahanian
c2d71b531c
This patch fixes code gen. part of pr5333 (Conversion
...
using elipsis conversion).
llvm-svn: 86276
2009-11-06 18:47:57 +00:00
Anders Carlsson
8a6512961f
Handle QualifiedNameType and SubstTemplateTypeParmType types in CGDebugInfo::CreateTypeNode.
...
llvm-svn: 86274
2009-11-06 18:45:16 +00:00
Anders Carlsson
421a5c9651
If a member variable of reference type is bound to a temporary in its member initializer it needs to be destroyed at the end of the constructor.
...
llvm-svn: 86230
2009-11-06 04:19:02 +00:00
Anders Carlsson
5852b13827
If a member initializer create temporaries we need to destroy them. Fixes PR5077.
...
llvm-svn: 86225
2009-11-06 04:11:09 +00:00
Anders Carlsson
9e4e0237e4
Handle ParenExprs in mangleExpression.
...
llvm-svn: 86218
2009-11-06 02:50:19 +00:00