[CodeGenObjCXX] Don't rematerialize default arguments of function
authorAkira Hatanaka <ahatanaka@apple.com>
Mon, 2 May 2016 21:52:57 +0000 (21:52 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Mon, 2 May 2016 21:52:57 +0000 (21:52 +0000)
commit3ba6535096a4a1abd57f7813183ac8fa0bccfc39
tree3c2977aee66c44f544d759f263df565f65766502
parent64f7a995b0f3b213e353486c5b6c6132f9bb124d
[CodeGenObjCXX] Don't rematerialize default arguments of function
parameters in the body of a block.

This fixes a bug where clang would materialize the default argument
inside the body of a block instead of passing the value via the block
descriptor.

For example, in the code below, foo1 would always print 42 regardless
of the value of argument "a" passed to foo1.

void foo1(const int a = 42 ) {
  auto block = ^{
    printf("%d\n", a);
  };
  block();
}

rdar://problem/24449235

llvm-svn: 268314
clang/lib/CodeGen/CGBlocks.cpp
clang/test/CodeGenObjCXX/block-default-arg.mm [new file with mode: 0644]