[all-commits] [llvm/llvm-project] f6b0ae: [AST] Accept identical TypeConstraint referring to...
Chuanqi Xu via All-commits
all-commits at lists.llvm.org
Tue Jul 12 08:58:45 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f6b0ae144ed8085618c12ba83d95affd786e6a49
https://github.com/llvm/llvm-project/commit/f6b0ae144ed8085618c12ba83d95affd786e6a49
Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
Date: 2022-07-12 (Tue, 12 Jul 2022)
Changed paths:
M clang/include/clang/AST/ASTContext.h
M clang/lib/AST/ASTContext.cpp
M clang/test/Modules/concept.cppm
Log Message:
-----------
[AST] Accept identical TypeConstraint referring to other template
parameters.
The current implementation to judge the similarity of TypeConstraint in
ASTContext::isSameTemplateParameter is problematic, it couldn't handle
the following case:
```C++
template <__integer_like _Tp, C<_Tp> Sentinel>
constexpr _Tp operator()(_Tp &&__t, Sentinel &&last) const {
return __t;
}
```
When we see 2 such declarations from different modules, we would judge
their similarity by `ASTContext::isSame*` methods. But problems come for
the TypeConstraint. Originally, we would profile each argument one by
one. But it is not right. Since the profiling result of `_Tp` would
refer to two different template type declarations. So it would get
different results. It is right since the `_Tp` in different modules
refers to different declarations indeed. So the same declaration in
different modules would meet incorrect our-checking results.
It is not the thing we want. We want to know if the TypeConstraint have
the same expression.
Reviewer: vsapsai, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D129068
More information about the All-commits
mailing list