[clang] [clang] Add invalid check in NormalizedConstraint::fromConstraintExpr. (PR #86943)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 28 10:52:34 PDT 2024
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/86943
>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 1/2] [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>,
>From efb0e700a7f007164cd73c7d43e22b01cb652da0 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Thu, 28 Mar 2024 18:52:08 +0100
Subject: [PATCH 2/2] Fix a typo
---
clang/lib/Sema/SemaConcept.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 61979816bf4e3c..b2986c5012ea2b 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1357,7 +1357,7 @@ NormalizedConstraint::fromConstraintExpr(Sema &S, NamedDecl *D, const Expr *E) {
Sema::InstantiatingTemplate::ConstraintNormalization{}, D,
CSE->getSourceRange());
if (Inst.isInvalid())
- return std::nullptr;
+ return std::nullopt;
// 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