[clang] Thread Safety Analysis: Basic capability alias-analysis (PR #142955)

Marco Elver via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 13 12:58:04 PDT 2025


================
@@ -6875,6 +6875,34 @@ class PointerGuard {
 };
 } // namespace Derived_Smart_Pointer
 
+// Test for capabilities that are heap-allocated and stored in static variables.
+namespace FunctionStaticVariable {
+struct Data {
+  Mutex mu;
+  int x GUARDED_BY(mu);
+};
+
+void testStaticVariable() {
+}
+
+void testHeapAllocation() {
+  static Data *d = new Data;
----------------
melver wrote:

Right, I started translateCXXNewExpr() because of this case, but then ended up solving this by ignoring isStaticLocal() variables - I've now moved that fix to the first patch as well.

So what's left for the translateCXXNewExpr patch is the `testStrangePattern()` test case, which would fail without it.

https://github.com/llvm/llvm-project/pull/142955


More information about the cfe-commits mailing list