]> granicus.if.org Git - clang/commit
[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)
commit9d274a49b1fc9874d470a004af4c50c58c93d876
tree0b369172fcd481a45bc48bcf3d0541f99a39711e
parentaba87a7ebcce24750d5d6845684c81345af0707b
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268314 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGBlocks.cpp
test/CodeGenObjCXX/block-default-arg.mm [new file with mode: 0644]