[clang] Thread Safety Analysis: Very basic capability alias-analysis (PR #142955)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 2 02:55:58 PDT 2025
================
@@ -1012,6 +1030,107 @@ void SExprBuilder::exitCFG(const CFGBlock *Last) {
IncompleteArgs.clear();
}
+bool SExprBuilder::isVariableReassigned(const VarDecl *VD) {
+ // Note: The search is performed lazily per-variable and result is cached. An
+ // alternative would have been to eagerly create a set of all reassigned
+ // variables, but that would consume significantly more memory. The number of
----------------
melver wrote:
I spoke too soon.
I might have found a way to use `LocalVariableMap`, and inject it into SExprBuilder in the right place. The tests pass and it appears to deal with e.g.
```
+void testBasicPointerAliasNoInit(Foo *f) {
+ Foo *ptr;
+
+ ptr = f;
+ ptr->mu.Lock();
+ f->data = 42;
+ ptr->mu.Unlock();
+}
+
```
Still trying to understand if this is actually sound, but if it is, this is far more powerful than before.
https://github.com/llvm/llvm-project/pull/142955
More information about the cfe-commits
mailing list