[NFC][Clang] Fix static analyzer concern about null value dereference
authorElizabeth Andrews <elizabeth.andrews@intel.com>
Mon, 14 Aug 2023 19:01:14 +0000 (12:01 -0700)
committerTobias Hieta <tobias@hieta.se>
Tue, 5 Sep 2023 07:00:27 +0000 (09:00 +0200)
Differential Revision: https://reviews.llvm.org/D157554

clang/lib/Sema/SemaExprCXX.cpp

index 423d537..08a025a 100644 (file)
@@ -9072,8 +9072,10 @@ Sema::BuildExprRequirement(
     MultiLevelTemplateArgumentList MLTAL(Param, TAL.asArray(),
                                          /*Final=*/false);
     MLTAL.addOuterRetainedLevels(TPL->getDepth());
-    Expr *IDC = Param->getTypeConstraint()->getImmediatelyDeclaredConstraint();
-    ExprResult Constraint = SubstExpr(IDC, MLTAL);
+    const TypeConstraint *TC = Param->getTypeConstraint();
+    assert(TC && "Type Constraint cannot be null here");
+    ExprResult Constraint =
+        SubstExpr(TC->getImmediatelyDeclaredConstraint(), MLTAL);
     if (Constraint.isInvalid()) {
       Status = concepts::ExprRequirement::SS_ExprSubstitutionFailure;
     } else {