From 34db84fdb092f89ea3678a0792074a5b9253829a Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 11 Dec 2012 19:58:01 +0000 Subject: [PATCH] objective-C blocks: Check for record type when deciding if byref variable requires extended layout info. to prevent a crash involving arrays declared __block. // rdar://12787751 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169908 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 2 +- test/CodeGenObjC/block-byref-variable-layout.m | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 44f13b6906..f3fa13584d 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4413,7 +4413,7 @@ bool ASTContext::getByrefLifetime(QualType Ty, return false; HasByrefExtendedLayout = false; - if (Ty->isAggregateType()) { + if (Ty->isRecordType()) { HasByrefExtendedLayout = true; LifeTime = Qualifiers::OCL_None; } diff --git a/test/CodeGenObjC/block-byref-variable-layout.m b/test/CodeGenObjC/block-byref-variable-layout.m index 6030661af4..9c8f6743be 100644 --- a/test/CodeGenObjC/block-byref-variable-layout.m +++ b/test/CodeGenObjC/block-byref-variable-layout.m @@ -40,3 +40,10 @@ int main() { }; c(); } + +// rdar://12787751 +typedef char mds_path_t[1024]; +void directVolumePerfWaitForStoreState() +{ + __block mds_path_t path; +} -- 2.40.0