[clang] [Clang] Guard against null in template instantiation process (PR #97913)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 6 14:51:19 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/97913
This patch adds a null check for InstantiatedFrom to prevent dereferencing a null pointer during the template instantiation process in clang::Sema::SetupConstraintScope().
The fix ensures that the function exits early with an appropriate error if the InstantiatedFrom pointer is not valid.
>From 47c87a6ba65fb2581737d8c15065a1e6c98a0944 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Sat, 6 Jul 2024 14:48:21 -0700
Subject: [PATCH] [Clang] Guard against null in template instantiation process
This patch adds a null check for InstantiatedFrom to prevent dereferencing a
null pointer during the template instantiation process in clang::Sema::SetupConstraintScope().
The fix ensures that the function exits early with an appropriate error if the
InstantiatedFrom pointer is not valid.
---
clang/lib/Sema/SemaConcept.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 202dd86c67f62..353276e9b2802 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -636,6 +636,9 @@ bool Sema::SetupConstraintScope(
? FD->getInstantiatedFromMemberFunction()
: FD->getInstantiatedFromDecl();
+ if (!InstantiatedFrom)
+ return true;
+
InstantiatingTemplate Inst(
*this, FD->getPointOfInstantiation(),
Sema::InstantiatingTemplate::ConstraintsCheck{}, InstantiatedFrom,
More information about the cfe-commits
mailing list