================
@@ -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;
----------------
Xazax-hun wrote:
Sorry, I just realized how easy to misunderstand my point here. What I meant
was, I wonder if for `noescape` arguments we might want to warn as soon as the
assignment to the global happens? That being said, I think it might be fine not
to do that if we cover the `save_globals` style scenario later on down the
line.
https://github.com/llvm/llvm-project/pull/181646
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits