[all-commits] [llvm/llvm-project] b3ce87: Make evaluation of nested requirement consistent w...

Utkarsh Saxena via All-commits all-commits at lists.llvm.org
Mon Dec 19 11:22:21 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b3ce87285186ba190103a90b0b49da2e45fb7d1f
      https://github.com/llvm/llvm-project/commit/b3ce87285186ba190103a90b0b49da2e45fb7d1f
  Author: Utkarsh Saxena <usx at google.com>
  Date:   2022-12-19 (Mon, 19 Dec 2022)

  Changed paths:
    M clang/include/clang/AST/ASTConcept.h
    M clang/include/clang/AST/ASTNodeTraverser.h
    M clang/include/clang/AST/ExprConcepts.h
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/ASTConcept.cpp
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/AST/StmtProfile.cpp
    M clang/lib/Sema/SemaConcept.cpp
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M clang/lib/Serialization/ASTWriterStmt.cpp
    M clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
    M clang/test/PCH/cxx2a-requires-expr.cpp
    M clang/tools/libclang/CIndex.cpp

  Log Message:
  -----------
  Make evaluation of nested requirement consistent with requires expr.

Fixes: https://github.com/llvm/llvm-project/issues/45563
```
template<class T>  concept True = true;

template <class T>
concept C1 = requires (T) {
   requires True<typename T::value> || True<T>;
};

template <class T>
constexpr bool foo()
requires True<typename T::value> || True<T> {
    return true;
}
static_assert(C1<double>); // Previously failed due to SFINAE error
static_assert(foo<int>()); // but this works fine.
```
The issue here is the discrepancy between how a [nested requirement is evaluated](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaTemplateInstantiate.cpp#L2331) Vs how a [non-nested requirement is evaluated](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaConcept.cpp#L167-L200).

This patch makes constraint checking consistent for nested requirement
and trailing requires expressions by reusing the same evaluator.

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




More information about the All-commits mailing list