[clang] [Modules] No transitive source location change (PR #86912)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 19:02:08 PDT 2024
ChuanqiXu9 wrote:
> Could you share the rest of the "no transitive change" patches, or at least their outline? I'm curious what else goes into making that work.
Oh, I haven't started them. The patch in my mind includes two at least:
(1) Add a new block recording the semantical hash value of the current named module.
(2) A similar patch for DeclID to refactor the existing linear offset to {ModuleFileIndex, LocalDeclID} patch.
BTW, with (2), maybe we can refactor the existing super large vector of Decls, `DeclsLoaded`, in the ASTReader into a array of vectors or into a map. But this may not be included in the series of the patches.
The motivation for (1) is that:
```
export module a;
export import b;
...
```
We want the BMI of `a` to change all the time if `b` changes.
Also for the motivation example, if we changed the definition of `funcB` into `inline`,
```
//--- A.cppm
export module A;
export inline int funcA() {
return 43;
}
//--- B.cppm
export module B;
import A;
export inline int funcB() {
return funcA();
}
```
We hope the BMI of module B will change after the function A changes. But the declaration level hash may be tricky, so probably we need to change the BMI of the module B after the module A changes as the initial step.
So the result may be, we need to add a new hash or signature value to the BMI for named modules:
```
signature = hash_combine(hash value of the current buffer, combined hash value of the signature export imported modules, combined hash value of touched non-export import modules)
```
(Maybe we need to do this for all module types)
Maybe we can reuse the existing ASTSignature or we need to add a new block. But I am sure about this point now.
https://github.com/llvm/llvm-project/pull/86912
More information about the cfe-commits
mailing list