[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision. ahatanak added a comment. This revision is now accepted and ready to land. This one can be closed. Repository: rL LLVM https://reviews.llvm.org/D32210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http:/

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak reopened this revision. ahatanak added a comment. Reopening this review. I accidentally closed this review when I committed r313717 (the patch that adds support for 'noescape'). Repository: rL LLVM https://reviews.llvm.org/D32210 ___ cf

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-19 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL313722: Add support for attribute 'noescape'. (authored by ahatanak). Changed prior to commit: https://reviews.llvm.org/D32210?vs=115432&id=115965#toc Repository: rL LLVM https://reviews.llvm.org/D3

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. Thanks, that looks good. https://reviews.llvm.org/D32210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: lib/Sema/SemaExpr.cpp:7251 +if (const auto *rhproto = dyn_cast(rhptee)) + rhptee = S.removeNoEscapeFromFunctionProto(lhproto, rhproto); + rjmccall wrote: > ahatanak wrote: > > rjmccall wrote: > > > I think the

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-09-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 115432. ahatanak added a comment. Address review comments. The new patch defines a new function "mergeExtParameterInfo" that merges two functions' ExtParameterInfo lists and uses it where previously doFunctionTypesMatchOnExtParameterInfos was used. https

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: lib/Sema/SemaDeclCXX.cpp:14024 + + if (OldFT->hasExtParameterInfos()) +for (unsigned I = 0, E = OldFT->getNumParams(); I != E; ++I) ahatanak wrote: > rjmccall wrote: > > I think we generally encourage the uses of b

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: lib/AST/ItaniumMangle.cpp:2700 + if (FD->getParamDecl(I)->hasAttr()) +Out << "U8noescape"; } rjmccall wrote: > This is not the right place to do this: > > * It needs to be mangled in function types, n

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 110612. ahatanak marked 6 inline comments as done. ahatanak added a comment. Address review comments. https://reviews.llvm.org/D32210 Files: include/clang/AST/Type.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/Di

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments. Comment at: include/clang/Basic/AttrDocs.td:138 +Additionally, for block pointers, the same restriction apply to copies of +blocks. For example: + ``` Additionally, when the parameter is a `block pointer

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: lib/CodeGen/CGCall.cpp:2096 +if (FI.getExtParameterInfo(ArgNo).isNoEscape()) + Attrs.addAttribute(llvm::Attribute::NoCapture); + rjmccall wrote: > ahatanak wrote: > > rjmccall wrote: > > > You should make sure

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-08-04 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 109814. ahatanak added a comment. Include noescape attribute information in the function prototype and modify the AST printer and name mangling accordingly. Also, make changes to allow implicit conversion from a function that takes noescape parameters to a

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-25 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. In https://reviews.llvm.org/D32210#819577, @ahatanak wrote: > In https://reviews.llvm.org/D32210#810508, @rjmccall wrote: > > > Hmm. Unfortunately, I'm not sure that's valid. The retains and releases > > of block captures don't protect against anything related to esca

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 107993. ahatanak marked an inline comment as done. ahatanak added a comment. Herald added a subscriber: javed.absar. Address review comments. https://reviews.llvm.org/D32210 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/c

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done. ahatanak added a comment. In https://reviews.llvm.org/D32210#810508, @rjmccall wrote: > In https://reviews.llvm.org/D32210#810292, @ahatanak wrote: > > > Address review comments. > > > > - Allow attaching "noescape" to pointers other than block pointers.

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. In https://reviews.llvm.org/D32210#810292, @ahatanak wrote: > Address review comments. > > - Allow attaching "noescape" to pointers other than block pointers. Update > the docs accordingly. > - Attach attribute "nocapture" to parameters that are annotated with > "noesc

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-07-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 106735. ahatanak marked 3 inline comments as done. ahatanak added a comment. Address review comments. - Allow attaching "noescape" to pointers other than block pointers. Update the docs accordingly. - Attach attribute "nocapture" to parameters that are anno

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. I agree with Aaron, it would be nice if this had some immediate effect. One obvious suggestion: take advantage of it in code generation. LLVM already has a parameter attribute called "nocapture" which conveys exactly the right semantics for noescape pointers and refe

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. The attribute is not used anywhere; the initial utility should be part of the patch introducing the attribute, unless that utility makes the patch very large. Comment at: lib/Sema/SemaDeclAttr.cpp:1522-1523 + QualType T = cast(D)->getType(); +

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-25 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: include/clang/Basic/AttrDocs.td:118 + let Content = [{ +``noescape`` placed on a block parameter is used to inform the compiler that the block passed to a function cannot escape: that is, the block will not be invoked after the funct

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-25 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 96637. ahatanak marked 4 inline comments as done. ahatanak added a comment. Address review comments. https://reviews.llvm.org/D32210 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/S

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. In https://reviews.llvm.org/D32210#731192, @ahatanak wrote: > In https://reviews.llvm.org/D32210#730777, @rjmccall wrote: > > > The rule we actually want is that no reference to the block derived from > > the parameter value will survive after the function returns. You

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment. In https://reviews.llvm.org/D32210#730777, @rjmccall wrote: > The rule we actually want is that no reference to the block derived from the > parameter value will survive after the function returns. You can include > examples of things that would cause potential escape

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment. In https://reviews.llvm.org/D32210#730553, @jroelofs wrote: > This doesn't forbid assigning them to block properties... is that intentional? > > typedef void (^Block)(int); > > @interface Foo > @property Block B; > @end > > void foo(Foo *f, Block __attribut

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment. The rule we actually want is that no reference to the block derived from the parameter value will survive after the function returns. You can include examples of things that would cause potential escapes, but trying to actually lock down the list seems ill-advised. A

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread Adam Kemp via Phabricator via cfe-commits
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: ``` typede

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment. This doesn't forbid assigning them to block properties... is that intentional? typedef void (^Block)(int); @interface Foo @property Block B; @end void foo(Foo *f, Block __attribute__((noescape)) b) { f.B = b; } Comment at: includ

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: include/clang/Basic/Attr.td:1222 +def NoEscape : InheritableAttr { + let Spellings = [GCC<"noescape">, CXX11<"clang", "noescape">]; + let Subjects = SubjectList<[ParmVar], WarnDiag, "ExpectedParameter">; I do not

[PATCH] D32210: [Sema][ObjC] Add support for attribute "noescape"

2017-04-18 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision. This patch adds support for attribute "noescape", which is used to tell the compiler that a block passed to a function will not be called after the function returns. To ensure that the block does not escape, clang imposes the following restrictions on its usage: