TheRealAdamKemp added inline comments.

================
Comment at: include/clang/Basic/AttrDocs.td:122
+* Cannot be returned from a function
+* Cannot be captured by a block
+* Cannot be assigned to a variable
----------------
This may be too restrictive in some cases. Consider this:

```
typedef void (^BlockTy)();
void nonescapingFunc(__attribute__((noescape)) BlockTy);

void callerFunc(__attribute__((noescape)) BlockTy block) {
  nonescapingFunc(^{ block(); });
}
```

It sounds like the above code would give an error, but the capturing block is 
also nonescaping, which means it should be allowed. This is a useful pattern, 
and disallowing it would make these attributes very cumbersome.

The code could also be written like this:

```
typedef void (^BlockTy)();
void nonescapingFunc(__attribute__((noescape)) BlockTy);

void callerFunc(__attribute__((noescape)) BlockTy block) {
  BlockTy wrapBlock = ^{
    block();
  };
  nonescapingFunc(wrapBlock);
}
```

Again, I would expect that to not give an error or at least be able to decorate 
the declaration of `wrapBlock` to indicate that it is also nonescaping (can 
this attribute be applied to locals or only function arguments?).


https://reviews.llvm.org/D32210



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to