[clang] [Thread Analysis] Fix a bug in context update in alias-analysis (PR #178952)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 15 14:21:09 PST 2026


================
@@ -1726,20 +1725,29 @@ class BuildLockset : public ConstStmtVisitor<BuildLockset> {
   FactSet FSet;
   // The fact set for the function on exit.
   const FactSet &FunctionExitFSet;
+  // Use `LVarCtx` to keep track of the context at each program point, which
+  // will be used to translate DREs (by `SExprBuilder::translateDeclRefExpr`)
+  // to their canonical definitions:
----------------
aaronpuchert wrote:

There is already [an explanation](https://github.com/llvm/llvm-project/blob/llvmorg-23-init/clang/lib/Analysis/ThreadSafety.cpp#L392-L404) of the mechanism on `LocalVariableMap`:

```c++
// A LocalVariableMap maintains a map from local variables to their currently
// valid definitions.  It provides SSA-like functionality when traversing the
// CFG.  Like SSA, each definition or assignment to a variable is assigned a
// unique name (an integer), which acts as the SSA name for that definition.
// The total set of names is shared among all CFG basic blocks.
// Unlike SSA, we do not rewrite expressions to replace local variables declrefs
// with their SSA-names.  Instead, we compute a Context for each point in the
// code, which maps local variables to the appropriate SSA-name.  This map
// changes with each assignment.
//
// The map is computed in a single pass over the CFG.  Subsequent analyses can
// then query the map to find the appropriate Context for a statement, and use
// that Context to look up the definitions of variables.
```

I think that covers the same points.

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


More information about the cfe-commits mailing list