[all-commits] [llvm/llvm-project] 74258f: [C++20] [Modules] Allow Stmt::Profile to treat lam...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Tue Jul 11 01:18:38 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 74258f4189e2b6bacabd40ee6f588fd9d1b37741
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2023-07-11 (Tue, 11 Jul 2023)

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

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

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

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.

Differential Revision: https://reviews.llvm.org/D153957

More information about the All-commits mailing list