[clang] aeee4eb - Stop modifying trailing return types.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 2 01:42:46 PDT 2023


Author: Richard Smith
Date: 2023-04-02T01:41:49-07:00
New Revision: aeee4ebd689171c963aa5d973e14cb6e731eb147

URL: https://github.com/llvm/llvm-project/commit/aeee4ebd689171c963aa5d973e14cb6e731eb147
DIFF: https://github.com/llvm/llvm-project/commit/aeee4ebd689171c963aa5d973e14cb6e731eb147.diff

LOG: Stop modifying trailing return types.

This change reverts the functional change from D144626 but retains its
test. Instead of dealing with the possibility that a trailing requires
clause might have been rewritten into some other incorrect form, just
stop rewriting it.

No functionality changes intended.

Reviewed By: erichkeane, ChuanqiXu

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

Added: 
    

Modified: 
    clang/lib/AST/ASTContext.cpp
    clang/lib/Sema/SemaConcept.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index bd4f2ff024949..74826da6703f5 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6619,28 +6619,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/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 4ff86843dacc1..2882b10613fdc 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -704,26 +704,10 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
     Record = const_cast<CXXRecordDecl *>(Method->getParent());
   }
   CXXThisScopeRAII ThisScope(*this, Record, ThisQuals, Record != nullptr);
-  // We substitute with empty arguments in order to rebuild the atomic
-  // constraint in a constant-evaluated context.
-  // FIXME: Should this be a dedicated TreeTransform?
-  const Expr *RC = FD->getTrailingRequiresClause();
-  llvm::SmallVector<Expr *, 1> Converted;
-
-  if (CheckConstraintSatisfaction(
-          FD, {RC}, Converted, *MLTAL,
-          SourceRange(UsageLoc.isValid() ? UsageLoc : FD->getLocation()),
-          Satisfaction))
-    return true;
-
-  // FIXME: we need to do this for the function constraints for
-  // comparison of constraints to work, but do we also need to do it for
-  // CheckInstantiatedFunctionConstraints?  That one is more 
diff icult, but we
-  // seem to always just pick up the constraints from the primary template.
-  assert(Converted.size() <= 1 && "Got more expressions converted?");
-  if (!Converted.empty() && Converted[0] != nullptr)
-    const_cast<FunctionDecl *>(FD)->setTrailingRequiresClause(Converted[0]);
-  return false;
+  return CheckConstraintSatisfaction(
+      FD, {FD->getTrailingRequiresClause()}, *MLTAL,
+      SourceRange(UsageLoc.isValid() ? UsageLoc : FD->getLocation()),
+      Satisfaction);
 }
 
 


        


More information about the cfe-commits mailing list