Index: lib/Sema/SemaExprObjC.cpp =================================================================== --- lib/Sema/SemaExprObjC.cpp (revision 217780) +++ lib/Sema/SemaExprObjC.cpp (working copy) @@ -768,6 +768,10 @@ if (Converted.isInvalid()) return ExprError(); + // Array literal index may have expressions which require + // cleanup. + Converted = MaybeCreateExprWithCleanups(Converted.get()); + ElementsBuffer[I] = Converted.get(); } @@ -951,6 +955,9 @@ = CheckObjCCollectionLiteralElement(*this, Elements[I].Value, ValueT); if (Value.isInvalid()) return ExprError(); + // Dictionary literal value may have expressions which require + // cleanup. + Value = MaybeCreateExprWithCleanups(Value.get()); Elements[I].Key = Key.get(); Elements[I].Value = Value.get(); Index: test/CodeGenObjCXX/lambda-in-objc-literals.mm =================================================================== --- test/CodeGenObjCXX/lambda-in-objc-literals.mm (revision 0) +++ test/CodeGenObjCXX/lambda-in-objc-literals.mm (working copy) @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks +// rdar://16879958 + +@protocol NSCopying @end +typedef unsigned long NSUInteger; +typedef long NSInteger; + +@interface NSDictionary ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(NSUInteger)cnt; +- (void)setObject:(id)object forKeyedSubscript:(id)key; +- (id)objectForKeyedSubscript:(id)key; ++ (id) alloc; +- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +@end + +@interface NSString +@end + + +@class NSFastEnumerationState; + +@protocol NSFastEnumeration + +- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len; + +@end + +@interface NSNumber ++ (NSNumber *)numberWithInt:(int)value; +@end + +@interface NSArray ++ (id) alloc; ++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; +@end + +id test_dict() +{ + return @{ + @"a": [](){}, + @"b": [](){}, + @"c": [](){} + }; +} + +id test_arr() +{ + return @[ + [](){}, + [](){} + ]; +}