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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 1 14:50:45 PDT 2017


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<ParmVarDecl>(D)->getType();
+  if (!T->isAnyPointerType() && !T->isBlockPointerType() &&
+      !T->isReferenceType() && !T->isArrayType() && !T->isMemberPointerType()) {
+    S.Diag(Attr.getLoc(), diag::warn_attribute_noescape_non_pointer) << T;
----------------
I don't think the type checking here is correct, at least according to the documentation. For instance, you don't appear to care whether the parameter is an array of block pointers vs an array of ints. Similar for the other composite types.


================
Comment at: test/SemaObjCXX/noescape.mm:8
+void invalidFunc(int __attribute__((noescape))); // expected-warning {{'noescape' attribute ignored on parameter of non-pointer type}}
+int __attribute__((noescape)) g; // expected-warning {{'noescape' attribute only applies to parameters}}
----------------
You should also have a test ensuring the attribute diagnoses when given an argument.


https://reviews.llvm.org/D32210





More information about the cfe-commits mailing list