This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by ChuanqiXu on Jun 28 2023, 2:24 AM.

Details

Summary

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.

Diff Detail

Event Timeline

ChuanqiXu created this revision.Jun 28 2023, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 2:24 AM
ChuanqiXu requested review of this revision.Jun 28 2023, 2:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 2:24 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a subscriber: shafik.Jun 28 2023, 10:37 AM
shafik added inline comments.
clang/lib/AST/StmtProfile.cpp
188–189

nit

Address comments.

I'd like to land this in the next week if no objections come in. Since clang-17 is going to be branched and this one is small and relevant. Also this one prevents the testing of the std modules.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 11 2023, 1:18 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.