Use thread annotations
Clang 8 (and maybe earlier) has support for Thread Safety Analysis:
https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
that allows thread annotations like GUARDED_BY
, REQUIRES(...)
and others to annotate variables, pointers and functions with hints for the analysis engine.