================ @@ -254,6 +255,31 @@ forget to add the reinitialization for this additional member. Instead, it is safer to assign to the entire struct in one go, and this will also avoid the use-after-move warning. +Coroutines +---------- + +This check also searches for occurrences of "use-after-suspend" in C++ +coroutines. This can be used, for example, to detect when a coroutine accesses +thread-local data after a suspension point (i.e. ``co_yield`` or ``co_await``), +where the reference or pointer used to access the data was acquired prior to the +suspension point. Such situations can be dangerous as the referenced memory may +belong to a different thread after suspension, or have been deallocated +entirely by the time the coroutine resumes. + +Note that, for any use-after-suspend to be flagged, ``NonlocalAccessors`` must +be non-empty actually match some functions. For example, if we have: + +.. code-block:: c++ + + CustomAwaitable AwaitResponse(); + + int* thread_data = GetThreadLocalData(); + co_await AwaitResponse(); // suspension + return *thread_data; // use after suspension + +then ``NonlocalAccessors`` must match ``GetThreadLocalData``, and ``Awaitables`` ---------------- EugeneZelenko wrote:
Ditto for `NonlocalAccessors` and `Awaitables`.. https://github.com/llvm/llvm-project/pull/172566 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
