Home | History | Annotate | Download | only in CodeGenObjCXX
      1 // RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s
      2 // rdar://9362021
      3 
      4 @class DYFuture;
      5 @interface NSCache
      6 - (void)setObject:(id)obj forKey:(id)key;
      7 @end
      8 
      9 template <typename T>
     10 class ResourceManager
     11 {
     12 public:
     13  ~ResourceManager();
     14  DYFuture* XXX();
     15  NSCache* _spDeviceCache;
     16 };
     17 
     18 template <typename T>
     19 DYFuture* ResourceManager<T>::XXX()
     20 {
     21  ^ {
     22    [_spDeviceCache setObject:0 forKey:0];
     23   }();
     24 
     25  return 0;
     26 }
     27 
     28 struct AnalyzerBaseObjectTypes { };
     29 
     30 void FUNC()
     31 {
     32     ResourceManager<AnalyzerBaseObjectTypes> *rm;
     33     ^(void) { rm->XXX(); }();
     34 }
     35 
     36 namespace PR9982 {
     37   template<typename T> struct Curry;
     38 
     39   template<typename R, typename Arg0, typename Arg1, typename Arg2>
     40     struct Curry<R (^)(Arg0, Arg1, Arg2)>
     41     {
     42       typedef R (^FType)(Arg0, Arg1, Arg2);
     43     
     44     Curry(FType _f) : f(_f) {}
     45       ~Curry() {;}
     46     
     47       R (^(^operator()(Arg0 a))(Arg1))(Arg2) 
     48       { 
     49         auto block = ^(Arg1 b) {
     50           auto inner_block = ^(Arg2 c) {
     51             return f(a, b, c);
     52           };
     53           return inner_block; 
     54         };
     55         return block;
     56       }
     57     
     58     private:
     59       FType f;
     60     };
     61 
     62   auto add = ^(int a, int b, int c)
     63     {
     64       return a + b + c;
     65     };
     66 
     67   void curry() {
     68     Curry<__decltype(add)> c = Curry<__decltype(add)>(add);
     69     auto t = c(1)(10)(100);
     70   }
     71 }
     72