[clang] [C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #109167)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 18 19:13:53 PDT 2024
ChuanqiXu9 wrote:
Would you like to explain more why this fail previously in more detail?
Also I am thinking if we can make the process more efficiently:
(1) Can we avoid the visitor in the writing process?
(2) Can we delay the loading of lambdas to the load of definitions of the functions?
I immediately expectation is that (1) is possible but (2) may not be not safe.
For (1), my idea is to record/register the information during the writing of LambdaExpr in ASTWriterStmt and then we can write this record after we write all the decls and types. Then we need to read this record eagerly. Maybe we can optimize it further by adding a slot in FunctionDecl to record the offset of such informations. So we can avoid the eager linear reading process.
For (2), whether or not it is safe is, can we we load the lambdas without loading the definition of the functions? If not, we can add a code when getting the definition of the functions like:
```
if (lambdas not loaded)
getCanonicalDecl()->loadLambdas();
```
Then we can delay the loading of the lambdas to make it more efficient.
https://github.com/llvm/llvm-project/pull/109167
More information about the cfe-commits
mailing list