2012-06-20 14:18:46 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s
|
2011-06-16 07:02:42 +08:00
|
|
|
|
|
|
|
// rdar://problem/9158302
|
|
|
|
// This should not use a memmove_collectable in non-GC mode.
|
|
|
|
namespace test0 {
|
|
|
|
struct A {
|
|
|
|
id x;
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: define [[A:%.*]]* @_ZN5test04testENS_1AE(
|
|
|
|
// CHECK: alloca
|
|
|
|
// CHECK-NEXT: getelementptr
|
|
|
|
// CHECK-NEXT: store
|
2016-04-08 05:46:12 +08:00
|
|
|
// CHECK-NEXT: call i8* @_Znwm(
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(
|
|
|
|
// CHECK-NEXT: ret
|
|
|
|
A *test(A a) {
|
|
|
|
return new A(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
fix rdar://9780211 - Clang crashes with an assertion failure building WKView.mm from WebKit
This is something of a hack, the problem is as follows:
1. we instantiate both copied of RetainPtr with the two different argument types
(an id and protocol-qualified id).
2. We refer to the ctor of one of the instantiations when introducing global "x",
this causes us to emit an llvm::Function for a prototype whose "this" has type
"RetainPtr<id<bork> >*".
3. We refer to the ctor of the other instantiation when introducing global "y",
however, because it *mangles to the same name as the other ctor* we just use
a bitcasted version of the llvm::Function we previously emitted.
4. We emit deferred declarations, causing us to emit the body of the ctor, however
the body we emit is for RetainPtr<id>, which expects its 'this' to have an IR
type of "RetainPtr<id>*".
Because of the mangling collision, we don't have this case, and explode.
This is really some sort of weird AST invariant violation or something, but hey
a bitcast makes the pain go away.
llvm-svn: 135572
2011-07-20 14:29:00 +08:00
|
|
|
|
|
|
|
// rdar://9780211
|
|
|
|
@protocol bork
|
|
|
|
@end
|
|
|
|
|
|
|
|
namespace test1 {
|
|
|
|
template<typename T> struct RetainPtr {
|
|
|
|
RetainPtr() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
RetainPtr<id<bork> > x;
|
|
|
|
RetainPtr<id> y;
|
|
|
|
|
|
|
|
}
|