From 5bb3253cf5b47dd49f431896b8d6412947a848f1 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Wed, 1 Mar 2023 11:03:37 +0800 Subject: [PATCH] Revert "[C++20] [Modules] Trying to compare the trailing require clause from the primary template function" This reverts commit 9e50578ba43c49ee13ac3bb7d4868565824f9b29. Since it looks like this one prevents us to fix the modular build for libcxx. --- clang/lib/AST/ASTContext.cpp | 24 +----------- clang/test/Modules/pr60890.cppm | 82 ----------------------------------------- 2 files changed, 2 insertions(+), 104 deletions(-) delete mode 100644 clang/test/Modules/pr60890.cppm diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 00b339f..4182986 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -6683,28 +6683,8 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const NamedDecl *Y) const { return false; } - // The trailing require clause of instantiated function may change during - // the semantic analysis. Trying to get the primary template function (if - // exists) to compare the primary trailing require clause. - auto TryToGetPrimaryTemplatedFunction = - [](const FunctionDecl *FD) -> const FunctionDecl * { - switch (FD->getTemplatedKind()) { - case FunctionDecl::TK_DependentNonTemplate: - return FD->getInstantiatedFromDecl(); - case FunctionDecl::TK_FunctionTemplate: - return FD->getDescribedFunctionTemplate()->getTemplatedDecl(); - case FunctionDecl::TK_MemberSpecialization: - return FD->getInstantiatedFromMemberFunction(); - case FunctionDecl::TK_FunctionTemplateSpecialization: - return FD->getPrimaryTemplate()->getTemplatedDecl(); - default: - return FD; - } - }; - const FunctionDecl *PrimaryX = TryToGetPrimaryTemplatedFunction(FuncX); - const FunctionDecl *PrimaryY = TryToGetPrimaryTemplatedFunction(FuncY); - if (!isSameConstraintExpr(PrimaryX->getTrailingRequiresClause(), - PrimaryY->getTrailingRequiresClause())) + if (!isSameConstraintExpr(FuncX->getTrailingRequiresClause(), + FuncY->getTrailingRequiresClause())) return false; auto GetTypeAsWritten = [](const FunctionDecl *FD) { diff --git a/clang/test/Modules/pr60890.cppm b/clang/test/Modules/pr60890.cppm deleted file mode 100644 index 2560bec..0000000 --- a/clang/test/Modules/pr60890.cppm +++ /dev/null @@ -1,82 +0,0 @@ -// https://github.com/llvm/llvm-project/issues/60890 -// -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: split-file %s %t -// -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -fprebuilt-module-path=%t -o %t/b.pcm -// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/c.cppm -fprebuilt-module-path=%t -o %t/c.pcm -// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -S -emit-llvm -o - - -//--- a.cppm -export module a; - -export template -struct a { - friend void aa(a x) requires(true) {} - void aaa() requires(true) {} -}; - -export template struct a; - -export template -void foo(T) requires(true) {} - -export template void foo(double); - -export template -class A { - friend void foo<>(A); -}; - -//--- b.cppm -export module b; - -import a; - -void b() { - a _; - a __; -} - -//--- c.cppm -export module c; - -import a; - -struct c { - void f() const { - a _; - aa(_); - _.aaa(); - - a __; - aa(__); - __.aaa(); - - foo(5); - foo(3.0); - foo(A()); - } -}; - -//--- d.cpp -// expected-no-diagnostics -import a; -import b; -import c; - -void d() { - a _; - aa(_); - _.aaa(); - - a __; - aa(__); - __.aaa(); - - foo(5); - foo(3.0); - foo(A()); -} -- 2.7.4