================
@@ -113,12 +113,31 @@ View escape_through_unannotated_call(const MyObj& in
[[clang::noescape]]) { // e
return no_annotation_identity(in); // expected-note {{returned here}}
}
-View global_view;
+View global_view; // expected-note {{escapes to this global storage}}
-// FIXME: Escaping through a global variable is not detected.
-void escape_through_global_var(const MyObj& in [[clang::noescape]]) {
+void escape_through_global_var(const MyObj& in [[clang::noescape]]) { //
expected-warning {{parameter is marked [[clang::noescape]] but escapes}}
global_view = in;
}
+struct ObjWithStaticField {
+ static int *static_field; // expected-note {{escapes to this global storage}}
+};
+
+void escape_to_static_data_member(int *data [[clang::noescape]]) { //
expected-warning {{parameter is marked [[clang::noescape]] but escapes}}
+ ObjWithStaticField::static_field = data;
+}
+
+
+
+void escape_through_static_local(int *data [[clang::noescape]]) { //
expected-warning {{parameter is marked [[clang::noescape]] but escapes}}
+ static int *static_local; // expected-note {{escapes to this global storage}}
----------------
Xazax-hun wrote:
One might say `static_local` is not really global storage. I wonder if we
should say something like `storage with static lifetime` or `static storage`?
https://github.com/llvm/llvm-project/pull/181646
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits