Manman Ren | 63fd408 | 2013-03-20 16:59:38 +0000 | [diff] [blame] | 1 | //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 | |
| 25 | class TimerBase { |
| 26 | public: |
| 27 | TimerBase(); |
| 28 | virtual ~TimerBase(); |
| 29 | }; |
| 30 | |
| 31 | template <typename TimerFiredClass> class Timer : public TimerBase { |
| 32 | public: |
| 33 | typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*); |
| 34 | |
| 35 | Timer(TimerFiredClass* o, TimerFiredFunction f) |
| 36 | : m_object(o), m_function(f) { } |
| 37 | |
| 38 | private: |
| 39 | virtual void fired() { (m_object->*m_function)(this); } |
| 40 | |
| 41 | TimerFiredClass* m_object; |
| 42 | TimerFiredFunction m_function; |
| 43 | }; |
| 44 | |
| 45 | class ObjectCache { |
| 46 | public: |
| 47 | explicit ObjectCache(); |
| 48 | ~ObjectCache(); |
| 49 | |
| 50 | private: |
| 51 | Timer<ObjectCache> m_notificationPostTimer; |
| 52 | }; |
| 53 | |
| 54 | inline ObjectCache::ObjectCache() : m_notificationPostTimer(this, 0) { } |
| 55 | inline ObjectCache::~ObjectCache() { } |
| 56 | |
| 57 | ObjectCache *test() { |
| 58 | ObjectCache *dd = new ObjectCache(); |
| 59 | return dd; |
| 60 | } |