[clang] a726be3 - [NFC] Make sure we check an optional when checking function constraints
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 21 07:33:03 PDT 2022
Author: Erich Keane
Date: 2022-10-21T07:32:57-07:00
New Revision: a726be38756bf65dbe15912e779f0813fe5af01e
URL: https://github.com/llvm/llvm-project/commit/a726be38756bf65dbe15912e779f0813fe5af01e
DIFF: https://github.com/llvm/llvm-project/commit/a726be38756bf65dbe15912e779f0813fe5af01e.diff
LOG: [NFC] Make sure we check an optional when checking function constraints
For some reason the initial deferred concepts patch didn't add this
check, which someone noticed could cause a problem with other patches
applied. This makes sure we check these, so that an error condition
cannot cause us to crash.
Added:
Modified:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaConcept.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6091a0be01089..e84e6b22f2817 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7211,7 +7211,7 @@ class Sema final {
FunctionDecl *FD, llvm::Optional<ArrayRef<TemplateArgument>> TemplateArgs,
MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope);
- /// Used during constraint checking, sets up the constraint template arguemnt
+ /// Used during constraint checking, sets up the constraint template argument
/// lists, and calls SetupConstraintScope to set up the
/// LocalInstantiationScope to have the proper set of ParVarDecls configured.
llvm::Optional<MultiLevelTemplateArgumentList>
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 5d8d7a41f821c..9809ccb2ccc00 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -511,7 +511,7 @@ Sema::SetupConstraintCheckingTemplateArgumentsAndScope(
/*Pattern=*/nullptr,
/*ForConstraintInstantiation=*/true);
if (SetupConstraintScope(FD, TemplateArgs, MLTAL, Scope))
- return {};
+ return llvm::None;
return MLTAL;
}
@@ -547,6 +547,9 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
SetupConstraintCheckingTemplateArgumentsAndScope(
const_cast<FunctionDecl *>(FD), {}, Scope);
+ if (!MLTAL)
+ return true;
+
Qualifiers ThisQuals;
CXXRecordDecl *Record = nullptr;
if (auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
More information about the cfe-commits
mailing list