[clang] Fix #99858 (PR #99859)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 03:29:39 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Ahmet Faruk Aktaş (ahfakt)
<details>
<summary>Changes</summary>
Fix crash caused by template parameter pack expansion when no instantiation exist.
---
Full diff: https://github.com/llvm/llvm-project/pull/99859.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+2-2)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/99859
More information about the cfe-commits
mailing list