================
@@ -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}}
+ static_local = data;
+}
+
+thread_local int *thread_local_storage; // expected-note {{escapes to this
global storage}}
+
+void escape_through_thread_local(int *data [[clang::noescape]]) { //
expected-warning {{parameter is marked [[clang::noescape]] but escapes}}
+ thread_local_storage = data;
----------------
AbhinavPradeep wrote:
Right, that makes sense! I dont see too many valid reasons for why anything
derived from a noescape parameter should be assigned to a global in correct
code, even that global is cleared later on. However, given we plan to implement
the function side effect modelling, maybe we hold off on this for now?
https://github.com/llvm/llvm-project/pull/181646
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits