]> granicus.if.org Git - clang/commit
[ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 2]
authorKuba Mracek <mracek@apple.com>
Fri, 14 Apr 2017 16:53:25 +0000 (16:53 +0000)
committerKuba Mracek <mracek@apple.com>
Fri, 14 Apr 2017 16:53:25 +0000 (16:53 +0000)
commitc4587feee99dd91c20d4ea6474d22fdd6d8c93e2
tree78a395648ba8a6c9fda0f47722ea16e8120c30c3
parent249076e75ced1241b64a4cf0dff66924b7ccead6
[ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 2]

CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way:  lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). This patch keeps the loop variable alive for the whole loop by extending ForScope and registering the cleanup function inside EmitAutoVarAlloca.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300340 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGObjC.cpp
test/CodeGenObjC/arc-blocks.m
test/CodeGenObjCXX/arc-references.mm