https://github.com/ahfakt created 
https://github.com/llvm/llvm-project/pull/99859

Fix crash caused by template parameter pack expansion when no instantiation 
exist.

From a84e2af497f827996afe9a820904f9f1d2f9fb22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ahmet=20Faruk=20Akta=C5=9F?= <a.faruka...@outlook.com>
Date: Mon, 22 Jul 2024 13:28:01 +0300
Subject: [PATCH] Fix #99858

Fix crash caused by template parameter pack expansion when no instantiation 
exist.
---
 clang/lib/Sema/SemaTemplateVariadic.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp 
b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 3d4ccaf68c700..70ceea1dda65b 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -732,7 +732,7 @@ bool Sema::CheckParameterPacksForExpansion(
       llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
           CurrentInstantiationScope->findInstantiationOf(
               ParmPack.first.get<NamedDecl *>());
-      if (Instantiation->is<DeclArgumentPack *>()) {
+      if (Instantiation && Instantiation->is<DeclArgumentPack *>()) {
         // We could expand this function parameter pack.
         NewPackSize = Instantiation->get<DeclArgumentPack *>()->size();
       } else {
@@ -850,7 +850,7 @@ std::optional<unsigned> Sema::getNumArgumentsInExpansion(
         llvm::PointerUnion<Decl *, DeclArgumentPack *> *Instantiation =
             CurrentInstantiationScope->findInstantiationOf(
                 Unexpanded[I].first.get<NamedDecl *>());
-        if (Instantiation->is<Decl *>())
+        if (Instantiation && Instantiation->is<Decl *>())
           // The pattern refers to an unexpanded pack. We're not ready to 
expand
           // this pack yet.
           return std::nullopt;

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to