[all-commits] [llvm/llvm-project] edbea6: [clang] Correctly handle by-reference capture with...

jensmassberg via All-commits all-commits at lists.llvm.org
Wed Dec 7 07:01:34 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: edbea62f72f7b9a5ee19c709d675d6083789c71f
      https://github.com/llvm/llvm-project/commit/edbea62f72f7b9a5ee19c709d675d6083789c71f
  Author: Jens Massberg <massberg at google.com>
  Date:   2022-12-07 (Wed, 07 Dec 2022)

  Changed paths:
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaLambda.cpp
    M clang/lib/Sema/TreeTransform.h
    A clang/test/SemaCXX/lambda-pack-expansion.cpp
    M clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

  Log Message:
  -----------
  [clang] Correctly handle by-reference capture with an initializer that is a pack expansion in lambdas.

Ensure that the correct information whether an init-capture of a lambda
is passed by reference or by copy. This information is already computed
and has to be passed to the place where `NewInitCaptureType` is
created.

Before this fix it has been checked whether the VarDecl is a reference
type. This doesn't work for packed expansions, as the information
whether it is passed by reference or by copy is stored at the pattern of
a `PackExpansionType` and not at the type itself.

However, as the information has been already computed, we just have to
pass it.

Add tests that lambda captures with var decls which are reference types
are created in the AST and a disgnotics test for pack expansions.

Fixes #49266

Differential Revision: https://reviews.llvm.org/D139125




More information about the All-commits mailing list