[clang] Thread Safety Analysis: Very basic capability alias-analysis (PR #142955)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 29 16:06:46 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:
Changed to find all reassigned pointers in one pass.
> If you do it in a single pass, you can also keep only the set of local pointer variables that are not reassigned, and which have valid init expressions.
It seemed more complex to invert the set during construction, so I left it to denote "reassigned || invalid init".
> We already have this LocalVariableMap in ThreadSafety.cpp. Maybe we should reuse the results here?
I explored this angle for a while before the current approach, but this was a dead end. The alias substitution needs to happen during TIL generation. The LocalVariableMap, however, is part of a later, separate analysis stage (ThreadSafetyAnalyzer::runAnalysis) that consumes the CFG: `LocalVariableMap`'s purpose is different, per its comment above it is a map from local variables to their current valid definitions (in an SSA form).
https://github.com/llvm/llvm-project/pull/142955
More information about the cfe-commits
mailing list