[llvm-branch-commits] [clang] 6c6ea59 - [Concepts] Add check for dependent RC when checking function constraints
Saar Raz via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jan 30 10:54:40 PST 2020
Author: Saar Raz
Date: 2020-01-30T20:54:12+02:00
New Revision: 6c6ea5995f261f0baa2be8a216ad08186551c622
URL: https://github.com/llvm/llvm-project/commit/6c6ea5995f261f0baa2be8a216ad08186551c622
DIFF: https://github.com/llvm/llvm-project/commit/6c6ea5995f261f0baa2be8a216ad08186551c622.diff
LOG: [Concepts] Add check for dependent RC when checking function constraints
Do not attempt to check a dependent requires clause in a function constraint
(may be triggered by, for example, DiagnoseUseOfDecl).
(cherry picked from commit a424ef99e7b9821ec80564af3d3a8f091323a38c)
Added:
Modified:
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaExpr.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index e5c0fa28c11f..8fdc6023040f 100755
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -325,9 +325,10 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
ConstraintSatisfaction &Satisfaction,
SourceLocation UsageLoc) {
const Expr *RC = FD->getTrailingRequiresClause();
- assert(!RC->isInstantiationDependent() &&
- "CheckFunctionConstraints can only be used with functions with "
- "non-dependent constraints");
+ if (RC->isInstantiationDependent()) {
+ Satisfaction.IsSatisfied = true;
+ return false;
+ }
// We substitute with empty arguments in order to rebuild the atomic
// constraint in a constant-evaluated context.
// FIXME: Should this be a dedicated TreeTransform?
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4f777e7b981b..2a8302e9d227 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -333,11 +333,9 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
//
// See if this is a function with constraints that need to be satisfied.
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
- if (Expr *RC = FD->getTrailingRequiresClause()) {
+ if (FD->getTrailingRequiresClause()) {
ConstraintSatisfaction Satisfaction;
- bool Failed = CheckConstraintSatisfaction(FD, {RC}, /*TemplateArgs=*/{},
- SourceRange(Loc), Satisfaction);
- if (Failed)
+ if (CheckFunctionConstraints(FD, Satisfaction, Loc))
// A diagnostic will have already been generated (non-constant
// constraint expression, for example)
return true;
More information about the llvm-branch-commits
mailing list