]> granicus.if.org Git - clang/commit
Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."
authorVolodymyr Sapsai <vsapsai@apple.com>
Mon, 22 Jan 2018 22:29:24 +0000 (22:29 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Mon, 22 Jan 2018 22:29:24 +0000 (22:29 +0000)
commit96479389ab52506b58bffe00f22c26027f576953
treec23c9aa19fd3c7b21ee826bbaea712906ff6c5aa
parent0d816739a82da29748caf88570affb9715e18b69
Reland "[CodeGen] Fix crash when a function taking transparent union is redeclared."

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

Now the fix is in converting from ABIArgInfo type to VarDecl type and using
argument demotion when necessary.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls, ahatanak

Differential Revision: https://reviews.llvm.org/D41311

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323156 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGCall.cpp
test/CodeGen/kr-func-promote.c
test/CodeGen/transparent-union-redecl.c [new file with mode: 0644]
test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
test/Sema/transparent-union.c