This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG94c3b169785c: Fix crash in ObjC codegen introduced with… (authored by theraven).
Changed prior to commit: https://reviews.llvm.org/D123898?vs=423241&id=447127#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123898/new/ https://reviews.llvm.org/D123898 Files: clang/lib/CodeGen/CGObjCGNU.cpp clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm Index: clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm =================================================================== --- /dev/null +++ clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -triple x86_64-unknow-windows-msvc -S -emit-llvm -fobjc-runtime=gnustep-2.0 -o - %s + +// Regression test. Ensure that C++ arguments with non-trivial destructors +// don't crash the compiler. + +struct X +{ + int a; + ~X(); +}; + +@protocol Y +- (void)foo: (X)bar; +@end + + +void test(id<Y> obj) +{ + X a{12}; + [obj foo: a]; +} + Index: clang/lib/CodeGen/CGObjCGNU.cpp =================================================================== --- clang/lib/CodeGen/CGObjCGNU.cpp +++ clang/lib/CodeGen/CGObjCGNU.cpp @@ -2837,11 +2837,13 @@ // Enter the continuation block and emit a phi if required. CGF.EmitBlock(continueBB); if (msgRet.isScalar()) { - llvm::Value *v = msgRet.getScalarVal(); - llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2); - phi->addIncoming(v, nonNilPathBB); - phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB); - msgRet = RValue::get(phi); + // If the return type is void, do nothing + if (llvm::Value *v = msgRet.getScalarVal()) { + llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2); + phi->addIncoming(v, nonNilPathBB); + phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB); + msgRet = RValue::get(phi); + } } else if (msgRet.isAggregate()) { // Aggregate zeroing is handled in nilCleanupBB when it's required. } else /* isComplex() */ {
Index: clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm =================================================================== --- /dev/null +++ clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -triple x86_64-unknow-windows-msvc -S -emit-llvm -fobjc-runtime=gnustep-2.0 -o - %s + +// Regression test. Ensure that C++ arguments with non-trivial destructors +// don't crash the compiler. + +struct X +{ + int a; + ~X(); +}; + +@protocol Y +- (void)foo: (X)bar; +@end + + +void test(id<Y> obj) +{ + X a{12}; + [obj foo: a]; +} + Index: clang/lib/CodeGen/CGObjCGNU.cpp =================================================================== --- clang/lib/CodeGen/CGObjCGNU.cpp +++ clang/lib/CodeGen/CGObjCGNU.cpp @@ -2837,11 +2837,13 @@ // Enter the continuation block and emit a phi if required. CGF.EmitBlock(continueBB); if (msgRet.isScalar()) { - llvm::Value *v = msgRet.getScalarVal(); - llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2); - phi->addIncoming(v, nonNilPathBB); - phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB); - msgRet = RValue::get(phi); + // If the return type is void, do nothing + if (llvm::Value *v = msgRet.getScalarVal()) { + llvm::PHINode *phi = Builder.CreatePHI(v->getType(), 2); + phi->addIncoming(v, nonNilPathBB); + phi->addIncoming(CGM.EmitNullConstant(ResultType), nilPathBB); + msgRet = RValue::get(phi); + } } else if (msgRet.isAggregate()) { // Aggregate zeroing is handled in nilCleanupBB when it's required. } else /* isComplex() */ {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits