[clang] [clang][serialization] Fix crash on imported pack indexing type (PR #205965)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 28 18:44:43 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: LeeYoungJoon (IamYJLee)
<details>
<summary>Changes</summary>
The selected index of a PackIndexingType was not serialized, so on deserialization its canonical type was rebuilt as a dependent type, crashing CodeGen.
Difference in `Ty` during `CodeGenTypes::ConvertType` (https://github.com/llvm/llvm-project/blob/49cf5a7ba0ab76a1f700ce6407cea1713741bc01/clang/lib/CodeGen/CodeGenTypes.cpp#L415-L424)
### Before
```cpp
PackIndexingType 0x142914680 'int' sugar
|-SubstTemplateTypeParmPackType 0x1429145a0 'Ts' dependent contains_unexpanded_pack imported typename depth 0 index 0 ... Ts
| |-TypeAliasTemplate 0x142914318 'element'
| `-TemplateArgument pack '<int>'
| `-TemplateArgument type 'int'
| `-BuiltinType 0x14401cf10 'int'
|-ConstantExpr 0x142914630 '__size_t':'unsigned long'
| |-value: Int 0
| `-ImplicitCastExpr 0x1429145f0 '__size_t':'unsigned long' <IntegralCast>
| `-IntegerLiteral 0x1429145d0 'int' 0
`-SubstTemplateTypeParmType 0x142914650 'int' sugar imported typename depth 0 index 0 ... Ts pack_index 0 final
|-TypeAliasTemplate 0x142914318 'element'
`-BuiltinType 0x14401cf10 'int'
```
### After
```cpp
BuiltinType 0x14e02e710 'int'
```
Fixes https://github.com/llvm/llvm-project/issues/204479
---
Full diff: https://github.com/llvm/llvm-project/pull/205965.diff
1 Files Affected:
- (modified) clang/include/clang/AST/TypeProperties.td (+4-1)
``````````diff
diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td
index f16c10da430f9..e2168d0a00ff4 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -489,9 +489,12 @@ let Class = PackIndexingType in {
def : Property<"expansions", Array<QualType>> {
let Read = [{ node->getExpansions() }];
}
+ def : Property<"index", UnsignedOrNone> {
+ let Read = [{ node->getSelectedIndex() }];
+ }
def : Creator<[{
- return ctx.getPackIndexingType(pattern, indexExpression, isFullySubstituted, expansions);
+ return ctx.getPackIndexingType(pattern, indexExpression, isFullySubstituted, expansions, index);
}]>;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/205965
More information about the cfe-commits
mailing list