[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

Gábor Horváth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 7 16:10:18 PST 2019


xazax.hun marked 2 inline comments as done.
xazax.hun added inline comments.


================
Comment at: clang/test/Sema/attr-handles.cpp:20-21
+void ht(int __attribute__((acquire_handle(1))) *a); // expected-error {{'acquire_handle' attribute takes no arguments}}
+int it() __attribute__((release_handle)); // expected-warning {{'release_handle' only applies to non-function types; type here is 'int ()'}}
+int jt() __attribute__((use_handle)); // expected-warning {{'use_handle' only applies to non-function types; type here is 'int ()'}}
+int __attribute__((acquire_handle)) at; // expected-warning {{'acquire_handle' attribute only applies to functions, function pointers, and parameters}}
----------------
aaron.ballman wrote:
> These diagnostics look incorrect to me -- I thought we wanted the attribute to apply to function types?
> 
> You should also add some test cases where the attribute is applied to a function pointer type.
I think this one can be a bit confusing. We can apply this to the types of the parameter or the return type. I thought restricting to users to put it either on the parameter or the return type would make it more obvious what is the target of this attribute.  In case this is not idiomatic, I can let the user to attach it to the function type. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70469/new/

https://reviews.llvm.org/D70469





More information about the cfe-commits mailing list