Commit Graph

31124 Commits

Author SHA1 Message Date
Douglas Gregor d29fde248e Eliminate an incomplete/incorrect attempt to provide support for C++0x
unrestricted unions, which ended up attempting to initialize objects
in a union (which CodeGen isn't prepared for). Fixes PR9683.

llvm-svn: 135027
2011-07-13 02:14:02 +00:00
Eli Friedman 609ada27ce Silliness with commas, as reported at http://blog.regehr.org/archives/558 . As it turns out, this is my fault for not noticing this was an issue when I was looking at this a long time ago. :(
llvm-svn: 135026
2011-07-13 02:05:57 +00:00
John McCall ca2c56f20b Switch delete[] IR-generation over to the destroy framework,
which implicitly makes it EH-safe as well.

llvm-svn: 135025
2011-07-13 01:41:37 +00:00
Douglas Gregor 1c2e20d73d When compiling ::delete for a class with a virtual destructor, call
the complete destructor and then invoke the global delete
operator. Previously, we would invoke the deleting destructor, which
calls the wrong delete operator. Fixes PR10341.

llvm-svn: 135021
2011-07-13 00:54:47 +00:00
Richard Smith 26935e60b6 Correctly set up the list of virtual base classes for a CXXRecordDecl. Previously we got the source range wrong for everything in the virtual bases list.
llvm-svn: 135011
2011-07-12 23:49:11 +00:00
Fariborz Jahanian c87c8799ec revert fix for // rdar://9740328
llvm-svn: 135010
2011-07-12 23:20:13 +00:00
Bruno Cardoso Lopes 0aadf83f80 Revert r134946
llvm-svn: 135004
2011-07-12 22:30:58 +00:00
Argyrios Kyrtzidis a200973ead [arcmt] Also avoid 'weak' for forward references to objc classes.
llvm-svn: 135003
2011-07-12 22:16:25 +00:00
Argyrios Kyrtzidis ce9b739999 [arcmt] Before applying '__weak' check whether the objc class is annotated with objc_arc_weak_reference_unavailable
or is in a list of classes not supporting 'weak'.

rdar://9489367.

llvm-svn: 135002
2011-07-12 22:05:17 +00:00
Fariborz Jahanian c0f6af2103 objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. // rdar://9740328

llvm-svn: 135001
2011-07-12 22:05:16 +00:00
David Chisnall c2800aab7b Fix another typo (int -> id for captured_obj).
llvm-svn: 134998
2011-07-12 20:34:06 +00:00
John McCall 30317fda63 Generalize Cleanup::Emit's "isForEH" parameter into a set
of flags.  No functionality change.

llvm-svn: 134997
2011-07-12 20:27:29 +00:00
Peter Collingbourne 77b0e7f296 Implement -MG. Fixes PR9613
llvm-svn: 134996
2011-07-12 19:35:15 +00:00
Benjamin Kramer ae2d344384 Add more compiler workarounds. Should fix the build with old GCCs and MSVC.
llvm-svn: 134995
2011-07-12 18:37:23 +00:00
Douglas Gregor 7e6bfb4a0d In ARC mode, consider Objective-C lifetime types (object pointers and
block pointers) that don't have any qualification to be POD types. We
were previously considering them to be non-POD types, because this was
convenient in C++ for is_pod-like traits. However, we now end up
inferring lifetime in such cases (template arguments infer __strong),
so it is not necessary.

Moreover, we want rvalues of object type (which have their lifetime
stripped) to be PODs to allow, e.g., va_arg(arglist, id) to function
properly. Fixes <rdar://problem/9758798>.

llvm-svn: 134993
2011-07-12 17:28:52 +00:00
Fariborz Jahanian 7f4427fc60 Fix a bug where a local variable named 'self' is causing
implicit ivar accesses to go through the 'self' variable
rather than the real 'self' for the method. // rdar://9730771

llvm-svn: 134992
2011-07-12 17:16:56 +00:00
John McCall 5fa8e20878 Ugh, use this compiler workaround again.
llvm-svn: 134989
2011-07-12 16:53:04 +00:00
John McCall 4bd0fb1f09 Switch field destruction over to use the new destroyer-based API
and kill a lot of redundant code.

llvm-svn: 134988
2011-07-12 16:41:08 +00:00
Douglas Gregor 2207ec273a Improve name mangling for instantiation-dependent types that are not
dependent. This covers an odd class of types such as

  int (&)[sizeof(sizeof(T() + T()))];

which involve template parameters but, because of some trick typically
involving a form of expression that is never type-dependent, resolve
down to a non-dependent type. Such types need to be mangled
essentially as they were written in the source code (involving
template parameters), rather than via their canonical type.

In general, instantiation-dependent types should be mangled as
they were written in the source. However, since we can't do that now
without non-trivial refactoring of the AST (see the new FIXME), I've
gone for this partial solution: only use the as-written-in-the-source
mangling for these strange types that are instantiation-dependent but
not dependent. This provides better compatibility with previous
incarnations of Clang and with GCC. In the future, we'd like to get
this right.

Fixes <rdar://problem/9663282>.

llvm-svn: 134984
2011-07-12 15:18:55 +00:00
Benjamin Kramer a4fb836f06 Pop block scope after reading from it.
Found by valgrind.

llvm-svn: 134983
2011-07-12 14:11:05 +00:00
Jay Foad b804a2b751 Second attempt at de-constifying LLVM Types in FunctionType::get(),
StructType::get() and TargetData::getIntPtrType().

llvm-svn: 134982
2011-07-12 14:06:48 +00:00
Chandler Carruth 4678f67139 Work around a problem with a static helper's formulation in release
builds introduced in r134972:

lib/CodeGen/CGExpr.cpp:1294:7: error: no matching function for call to 'EmitBitCastOfLValueToProperType'
lib/CodeGen/CGExpr.cpp:1278:1: note: candidate function not viable: no known conversion from 'CGBuilderTy' (aka 'IRBuilder<false>') to 'llvm::IRBuilder<> &' for 1st argument

This fixes the issue by passing CodeGenFunction on down, and using its
builder directly rather than passing just the builder down.

This may not be the best / cleanest fix, Chris please review. It at
least fixes builds.

llvm-svn: 134977
2011-07-12 08:58:26 +00:00
Hans Wennborg 38198ded24 Fix typo correction crash on overloaded functions, pr10283.
It would be cool if we could do overload resolution to suggest
the right function, but at least this fixes the crashing.

llvm-svn: 134976
2011-07-12 08:45:31 +00:00
Douglas Gregor e5802234f9 Implement name mangling for sizeof...(function parameter pack).
llvm-svn: 134974
2011-07-12 07:03:48 +00:00
Douglas Gregor 4a80f9fd98 Fix the desugaring of dependent decltype and typeof(expr) nodes. The
isSugared() and desugar() routines previously provided were never
actually called, since the corresponding types
(DependentTypeOfExprType, DependentDecltypeType) don't have
corresponding type classes. Outside of the current (incomplete) patch
I'm working on, I haven't found a way to trigger this problem.

llvm-svn: 134973
2011-07-12 06:55:29 +00:00
Chris Lattner 3f32d69699 Fix a problem Eli ran into where we now reject incomplete arrays of
uncompleted struct types.  We now do what llvm-gcc does and compile
them into [i8 x 0].  If the type is later completed, we make sure that
it is appropriately cast.

We compile the terrible example to something like this now:

%struct.A = type { i32, i32, i32 }

@g = external global [0 x i8]

define void @_Z1fv() nounwind {
entry:
  call void @_Z3fooP1A(%struct.A* bitcast ([0 x i8]* @g to %struct.A*))
  ret void
}

declare void @_Z3fooP1A(%struct.A*)

define %struct.A* @_Z2f2v() nounwind {
entry:
  ret %struct.A* getelementptr inbounds ([0 x %struct.A]* bitcast ([0 x i8]* @g to [0 x %struct.A]*), i32 0, i64 1)
}

llvm-svn: 134972
2011-07-12 06:52:18 +00:00
Chris Lattner d59d867ca5 insert a bitcast in the 'expand' case of argument passing when needed. This
fixes the -m32 build of oggenc.

llvm-svn: 134971
2011-07-12 06:29:11 +00:00
Chris Lattner 73e3004e75 fix an unintended behavior change in the type system rewrite, which caused us to compile
stuff like this:

typedef struct {
 int x, y, z; 
} foo_t;

foo_t g;

into:
%"struct.<anonymous>" = type { i32, i32, i32 }
we now get:
%struct.foo_t = type { i32, i32, i32 }

This doesn't change the behavior of the compiler, but makes the IR much easier to read.

llvm-svn: 134969
2011-07-12 05:53:08 +00:00
Douglas Gregor 1cf9dd21dc Mangle dependent template names of unknown arity
llvm-svn: 134967
2011-07-12 05:06:05 +00:00
Chris Lattner 3ce8668273 fix PR10335 by watching out for IR type compatibility in call argument lists.
llvm-svn: 134966
2011-07-12 04:53:39 +00:00
Argyrios Kyrtzidis 9b72b0c7d5 Move OBJC_PR_NumBits out of PropertyAttributeKind enum, to its own NumPropertyAttrsBits.
No functionality change.

llvm-svn: 134965
2011-07-12 04:52:08 +00:00
Chris Lattner 5e3ef09f20 make test name less specific
llvm-svn: 134964
2011-07-12 04:51:05 +00:00
Douglas Gregor 6ef06cc48d Implement the Itanium C++ ABI's mangling rule for
non-instantiation-dependent sizeof and alignof expressions.

llvm-svn: 134963
2011-07-12 04:47:20 +00:00
Chris Lattner bb1952cfda add some aggressive assertions that call arguments match up to callee
expectations in EmitCall.  Next patch will take this further.

llvm-svn: 134962
2011-07-12 04:46:18 +00:00
Douglas Gregor 842806450c Centralize the getCanonicalType() calls in the Itanium C++ mangling
code so that they only occur in a single place. No functionality change.

llvm-svn: 134961
2011-07-12 04:42:08 +00:00
Argyrios Kyrtzidis 52bfc2b668 [ARC] Complain about property without storage attribute when @synthesizing it, not at its declaration.
For this sample:

@interface Foo
@property id x;
@end

we get:

t.m:2:1: error: ARC forbids properties of Objective-C objects with unspecified storage attribute
@property  id x;
^
1 error generated.

The error should be imposed on the implementor of the interface, not the user. If the user uses
a header of a non-ARC library whose source code he does not have, we are basically asking him to
go change the header of the library (bad in general), possible overriding how the property is
implemented if he gets confused and says "Oh I'll just add 'copy' then" (even worse).

Second issue is that we don't emit any error for 'readonly' properties, e.g:

@interface Foo
@property (readonly) id x; // no error  here
@end

@implementation Foo
@synthesize x; // no error here too
@end

We should give an error when the implementor is @synthesizing a property which doesn't have
any storage specifier; this is when the explicit specifier is important, because we are
going to create an ivar and we want its ownership to be explicit.

Related improvements:
-OBJC_PR_unsafe_unretained turned out to not fit in ObjCPropertyDecl's bitfields, fix it.
-For properties of extension classes don't drop PropertyAttributesAsWritten values.
-Have PropertyAttributesAsWritten actually only reflect what the user wrote

rdar://9756610.

llvm-svn: 134960
2011-07-12 04:30:16 +00:00
Bruno Cardoso Lopes 37b7fd0ab2 Fix a typo!
llvm-svn: 134952
2011-07-12 02:47:38 +00:00
Bruno Cardoso Lopes 75541d00e0 Do the same as r134946 for arrays. Add more testcases for avx x86_64 arg
passing.

llvm-svn: 134951
2011-07-12 01:27:38 +00:00
Bill Wendling 7475113d74 Revert r134888 (and related patches in other trees). It was causing
an assert on Darwin llvm-gcc builds.

Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, line 2067.
etc.

http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354

--- Reverse-merging r134888 into '.':
U    lib/CodeGen/CodeGenModule.cpp

llvm-svn: 134950
2011-07-12 01:16:47 +00:00
Bruno Cardoso Lopes 7a26681092 Fix one x86_64 abi issue and the test to actually look for the right thing,
which is: { <4 x float>, <4 x float> } should continue to go through memory.

llvm-svn: 134946
2011-07-12 00:30:27 +00:00
John McCall 5fcf8da33d Do full-expression cleanups in a much more sensible way that still lets
people write useful cleanup classes.

llvm-svn: 134942
2011-07-12 00:15:30 +00:00
Bruno Cardoso Lopes 3472838c7a Disable avx feature from corei7-avx, and use -mavx for now. Right now, if -mavx is
specified, 128 avx code is used and we're not sure yet if this the behavior
we want (and if it does, some improvements are needed before relying on it).

llvm-svn: 134939
2011-07-11 23:33:46 +00:00
Chandler Carruth 9312c6464d Style tweak to the more idiomatic 'assert(!bad_state())'.
Patch by Caitlin Sadowski.

llvm-svn: 134938
2011-07-11 23:33:05 +00:00
Chandler Carruth fcc48d9e71 Hoist the logic for checking the number of arguments to an attribute
into a static helper.

Original patch by Caitlin Sadowski, style tweaks by me.

llvm-svn: 134937
2011-07-11 23:30:35 +00:00
Bruno Cardoso Lopes 571419bae6 Enable "avx" feature, so it can be seen by llvm
llvm-svn: 134935
2011-07-11 22:50:13 +00:00
Bruno Cardoso Lopes 21a41bb5ec Reapply r134754, which turns out to be working correctly and also
add one more testcase.

llvm-svn: 134934
2011-07-11 22:41:29 +00:00
Douglas Gregor 2e12550e37 Allow us to compute linkage et al for instantiation-dependent types.
llvm-svn: 134932
2011-07-11 22:38:07 +00:00
NAKAMURA Takumi 9a9ec73665 Revert r134898, "test/Frontend/dependency-gen.c: Mark XFAIL: mingw due to PR10331. to appease mingw-target (and non-mingw-host) builds.
PR10331 is still alive I suppose.

llvm-svn: 134931
2011-07-11 22:34:14 +00:00
Argyrios Kyrtzidis bf65d2d820 Reenable test.
llvm-svn: 134928
2011-07-11 21:58:47 +00:00
Argyrios Kyrtzidis c645d60f12 Add missing header file for the test.
llvm-svn: 134927
2011-07-11 21:58:44 +00:00