aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprClassification.cpp
diff options
context:
space:
mode:
authorYounan Zhang <zyn7109@gmail.com>2024-05-01 11:52:14 +0800
committerGitHub <noreply@github.com>2024-05-01 11:52:14 +0800
commit410d6350eda322de213941b36adcdab13a0b557b (patch)
treedac571fb3f78d843a2dc374e59ab0bb43a4c45f3 /clang/lib/AST/ExprClassification.cpp
parent306ae14face205e1bf2557ca2443c781b1d862f5 (diff)
downloadllvm-410d6350eda322de213941b36adcdab13a0b557b.zip
llvm-410d6350eda322de213941b36adcdab13a0b557b.tar.gz
llvm-410d6350eda322de213941b36adcdab13a0b557b.tar.bz2
[Sema] Avoid an undesired pack expansion while transforming PackIndexingType (#90195)
A pack indexing type can appear in a larger pack expansion, e.g `Pack...[pack_of_indexes]...` so we need to temporarily disable substitution of pack elements. Besides, this patch also fixes an assertion failure in `PackIndexingExpr::classify`: dependent `PackIndexingExpr`s are always LValues and thus we don't need to consider their `IndexExpr`s. Fixes https://github.com/llvm/llvm-project/issues/88925 --------- Co-authored-by: cor3ntin <corentinjabot@gmail.com>
Diffstat (limited to 'clang/lib/AST/ExprClassification.cpp')
-rw-r--r--clang/lib/AST/ExprClassification.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp
index 2bb8f9a..390000e3 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -216,8 +216,13 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
return ClassifyInternal(Ctx,
cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement());
- case Expr::PackIndexingExprClass:
+ case Expr::PackIndexingExprClass: {
+ // A pack-index-expression always expands to an id-expression.
+ // Consider it as an LValue expression.
+ if (cast<PackIndexingExpr>(E)->isInstantiationDependent())
+ return Cl::CL_LValue;
return ClassifyInternal(Ctx, cast<PackIndexingExpr>(E)->getSelectedExpr());
+ }
// C, C++98 [expr.sub]p1: The result is an lvalue of type "T".
// C++11 (DR1213): in the case of an array operand, the result is an lvalue