[PATCH] D153957: [C++20] [Modules] Allow Stmt::Profile to treat lambdas as equal conditionally

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 28 02:24:17 PDT 2023


ChuanqiXu created this revision.
ChuanqiXu added reviewers: rsmith, cor3ntin, aaron.ballman, tbaeder.
ChuanqiXu added projects: clang-modules, clang-language-wg.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Close https://github.com/llvm/llvm-project/issues/63544.

Background: We landed std modules in libcxx recently but we haven't landed the corresponding in-tree tests. According to @Mordante, there are only 1% libcxx tests failing with std modules. And the major blocking issue is the lambda expression in the require clauses.

The root cause of the issue is that previously we never consider any lambda expression as the same. Per [temp.over.link]p5:

> Two lambda-expressions are never considered equivalent.

I thought this is an oversight at first but @rsmith explains that in the wording, the program is as if there is only a single definition, and a single lambda-expression. So we don't need worry about this in the spec. The explanation makes sense. But it didn't reflect to the implementation directly.

Here is a cycle in the implementation. If we want to merge two definitions, we need to make sure its implementation are the same. But according to the explanation above, we need to judge if two lambda-expression are the same by looking at its parent definitions. So here is the problem.

To solve the problem, I think we have to profile the lambda expressions actually to get the accurate information. But we can't do this universally. So in this patch I tried to modify the interface of `Stmt::Profile` and only profile the lambda expression during the process of merging the constraint expressions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153957

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/test/Modules/merge-requires-with-lambdas.cppm
  clang/test/Modules/pr63544.cppm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153957.535290.patch
Type: text/x-patch
Size: 10467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230628/c017e4aa/attachment-0001.bin>


More information about the cfe-commits mailing list