[all-commits] [llvm/llvm-project] 48bda0: [Clang] [Sema] Don't crash on unexpanded pack in i...

Sirraide via All-commits all-commits at lists.llvm.org
Fri Oct 11 11:04:05 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 48bda00b281a432d6de5e5e5dde6c5d66b992ac8
      https://github.com/llvm/llvm-project/commit/48bda00b281a432d6de5e5e5dde6c5d66b992ac8
  Author: Sirraide <aeternalmail at gmail.com>
  Date:   2024-10-11 (Fri, 11 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/ComputeDependence.h
    M clang/include/clang/AST/Expr.h
    M clang/include/clang/Sema/ScopeInfo.h
    M clang/include/clang/Sema/Sema.h
    M clang/include/clang/Sema/Template.h
    M clang/lib/AST/ComputeDependence.cpp
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaLambda.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaTemplateInstantiate.cpp
    M clang/lib/Sema/SemaTemplateVariadic.cpp
    M clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
    A clang/test/SemaCXX/block-packs.cpp

  Log Message:
  -----------
  [Clang] [Sema] Don't crash on unexpanded pack in invalid block literal (#110762)

Consider #109148:
```c++
template <typename ...Ts>
void f() {
    [] {
        (^Ts);
    };
}
```

When we encounter `^Ts`, we try to parse a block and subsequently call
`DiagnoseUnexpandedParameterPack()` (in `ActOnBlockArguments()`), which
sees `Ts` and sets `ContainsUnexpandedParameterPack` to `true` in the
`LambdaScopeInfo` of the enclosing lambda. However, the entire block is
subsequently discarded entirely because it isn’t even syntactically
well-formed. As a result, `ContainsUnexpandedParameterPack` is `true`
despite the lambda’s body no longer containing any unexpanded packs,
which causes an assertion the next time
`DiagnoseUnexpandedParameterPack()` is called.

This pr moves handling of unexpanded parameter packs into
`CapturingScopeInfo` instead so that the same logic is used for both
blocks and lambdas. This fixes this issue since the
`ContainsUnexpandedParameterPack` flag is now part of the block (and
before that, its `CapturingScopeInfo`) and no longer affects the
surrounding lambda directly when the block is parsed. Moreover, this
change makes blocks actually usable with pack expansion.

This fixes #109148.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list