blob: 1ff922de60f3958fc411753533d9f68a69632ad9 [file] [log] [blame]
Manman Ren63fd4082013-03-20 16:59:38 +00001//RUN: %clang_cc1 %s -emit-llvm -o - -triple=thumbv7-apple-ios3.0 -target-abi apcs-gnu | FileCheck %s
2
3// For constructors/desctructors that return 'this', if there exists a callsite
4// that returns 'this' and is immediately before the return instruction, make
5// sure we are using the return value from the callsite.
6// rdar://12818789
7
8// CHECK: define linkonce_odr [[A:%.*]] @_ZN11ObjectCacheC1Ev([[A]] %this) unnamed_addr
9// CHECK: [[THIS1:%.*]] = call [[A]] @_ZN11ObjectCacheC2Ev(
10// CHECK-NEXT: ret [[A]] [[THIS1]]
11
12// CHECK: define linkonce_odr [[A:%.*]] @_ZN5TimerI11ObjectCacheEC1EPS0_MS0_FvPS1_E([[A]] %this
13// CHECK: [[THIS1:%.*]] = call [[A]] @_ZN5TimerI11ObjectCacheEC2EPS0_MS0_FvPS1_E(
14// CHECK-NEXT: ret [[A]] [[THIS1]]
15
16// CHECK: define linkonce_odr [[A:%.*]] @_ZN5TimerI11ObjectCacheED1Ev([[A]] %this) unnamed_addr
17// CHECK: [[THIS1:%.*]] = call [[A]] @_ZN5TimerI11ObjectCacheED2Ev(
18// CHECK-NEXT: ret [[A]] [[THIS1]]
19
20// CHECK: define linkonce_odr [[A:%.*]] @_ZN5TimerI11ObjectCacheED2Ev([[A]] %this) unnamed_addr
21// CHECK: [[THIS1:%.*]] = call [[B:%.*]] @_ZN9TimerBaseD2Ev(
22// CHECK-NEXT: [[THIS2:%.*]] = bitcast [[B]] [[THIS1]] to [[A]]
23// CHECK-NEXT: ret [[A]] [[THIS2]]
24
25class TimerBase {
26public:
27 TimerBase();
28 virtual ~TimerBase();
29};
30
31template <typename TimerFiredClass> class Timer : public TimerBase {
32public:
33 typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*);
34
35 Timer(TimerFiredClass* o, TimerFiredFunction f)
36 : m_object(o), m_function(f) { }
37
38private:
39 virtual void fired() { (m_object->*m_function)(this); }
40
41 TimerFiredClass* m_object;
42 TimerFiredFunction m_function;
43};
44
45class ObjectCache {
46public:
47 explicit ObjectCache();
48 ~ObjectCache();
49
50private:
51 Timer<ObjectCache> m_notificationPostTimer;
52};
53
54inline ObjectCache::ObjectCache() : m_notificationPostTimer(this, 0) { }
55inline ObjectCache::~ObjectCache() { }
56
57ObjectCache *test() {
58 ObjectCache *dd = new ObjectCache();
59 return dd;
60}