]> granicus.if.org Git - clang/commit
PR23334: Perform semantic checking of lambda capture initialization in the right...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 27 Apr 2015 21:27:54 +0000 (21:27 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 27 Apr 2015 21:27:54 +0000 (21:27 +0000)
commit41bd0122fae3556ef3d9d90ba6ae910d40d68b6b
treeddfa1012df388c09d324c9005888327d0feed773
parent7808a191bec712a48859ebddcdb5ab708ca8eef7
PR23334: Perform semantic checking of lambda capture initialization in the right context.

Previously we'd try to perform checks on the captures from the middle of
parsing the lambda's body, at the point where we detected that a variable
needed to be captured. This was wrong in a number of subtle ways. In
PR23334, we couldn't correctly handle the list of potential odr-uses
resulting from the capture, and our attempt to recover from that resulted
in a use-after-free.

We now defer building the initialization expression until we leave the lambda
body and return to the enclosing context, where the initialization does the
right thing. This patch only covers lambda-expressions, but we should apply
the same change to blocks and captured statements too.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235921 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
include/clang/Sema/Sema.h
lib/Analysis/UninitializedValues.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaLambda.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/TreeTransform.h
test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp
test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
test/SemaCXX/PR23334.cpp [new file with mode: 0644]
test/SemaCXX/cxx1y-generic-lambdas.cpp
test/SemaCXX/uninitialized.cpp