summaryrefslogtreecommitdiff
path: root/clang/test/CodeGenObjCXX/block-in-template-inst.mm
blob: 93a0e4907d290dff00da2da5ece66c7e8c0bbec2 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s
// rdar://9362021

@class DYFuture;
@interface NSCache
- (void)setObject:(id)obj forKey:(id)key;
@end

template <typename T>
class ResourceManager
{
public:
 ~ResourceManager();
 DYFuture* XXX();
 NSCache* _spDeviceCache;
};

template <typename T>
DYFuture* ResourceManager<T>::XXX()
{
 ^ {
   [_spDeviceCache setObject:0 forKey:0];
  }();

 return 0;
}

struct AnalyzerBaseObjectTypes { };

void FUNC()
{
    ResourceManager<AnalyzerBaseObjectTypes> *rm;
    ^(void) { rm->XXX(); }();
}

namespace PR9982 {
  template<typename T> struct Curry;

  template<typename R, typename Arg0, typename Arg1, typename Arg2>
    struct Curry<R (^)(Arg0, Arg1, Arg2)>
    {
      typedef R (^FType)(Arg0, Arg1, Arg2);
    
    Curry(FType _f) : f(_f) {}
      ~Curry() {;}
    
      R (^(^operator()(Arg0 a))(Arg1))(Arg2) 
      { 
        auto block = ^(Arg1 b) {
          auto inner_block = ^(Arg2 c) {
            return f(a, b, c);
          };
          return inner_block; 
        };
        return block;
      }
    
    private:
      FType f;
    };

  auto add = ^(int a, int b, int c)
    {
      return a + b + c;
    };

  void curry() {
    Curry<__decltype(add)> c = Curry<__decltype(add)>(add);
    auto t = c(1)(10)(100);
  }
}