[clang] [clang] Add invalid check in NormalizedConstraint::fromConstraintExpr. (PR #86943)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 05:27:36 PDT 2024


https://github.com/hokein created https://github.com/llvm/llvm-project/pull/86943

This is an oversight spot in #86869, we should always check the invalid bit after constructing the `Sema::InstantiatingTemplate` RAII object.

>From cb863750a7c57e76bbb8d63cc88975f5adaa65aa Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Thu, 28 Mar 2024 13:23:51 +0100
Subject: [PATCH] [clang] Add invalid check in
 NormalizedConstraint::fromConstraintExpr.

This is an oversight spot in #86869, we should always check the invalid bit after
constructing the `Sema::InstantiatingTemplate` RAII object.
---
 clang/lib/Sema/SemaConcept.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index a2d8ba9a96d7a4..61979816bf4e3c 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1356,6 +1356,8 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
           S, CSE->getExprLoc(),
           Sema::InstantiatingTemplate::ConstraintNormalization{}, D,
           CSE->getSourceRange());
+      if (Inst.isInvalid())
+        return std::nullptr;
       // C++ [temp.constr.normal]p1.1
       // [...]
       // The normal form of an id-expression of the form C<A1, A2, ..., AN>,



More information about the cfe-commits mailing list