[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
Showing
- lib/CodeGen/CGDecl.cpp 6 additions, 7 deletionslib/CodeGen/CGDecl.cpp
- lib/CodeGen/CGObjC.cpp 2 additions, 2 deletionslib/CodeGen/CGObjC.cpp
- test/CodeGenObjC/arc-blocks.m 3 additions, 3 deletionstest/CodeGenObjC/arc-blocks.m
- test/CodeGenObjCXX/arc-references.mm 2 additions, 2 deletionstest/CodeGenObjCXX/arc-references.mm
Loading
Please register or sign in to comment