[NFC] Make sure we check an optional when checking function constraints
authorErich Keane <erich.keane@intel.com>
Fri, 21 Oct 2022 14:31:26 +0000 (07:31 -0700)
committerErich Keane <erich.keane@intel.com>
Fri, 21 Oct 2022 14:32:57 +0000 (07:32 -0700)
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.

clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaConcept.cpp

index 6091a0b..e84e6b2 100644 (file)
@@ -7211,7 +7211,7 @@ private:
       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>
index 5d8d7a4..9809ccb 100644 (file)
@@ -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)) {