зеркало из https://github.com/microsoft/clang-1.git
Fix a codegen crash on void ?: reported by Oliver
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44454 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
c69a5810f4
Коммит
2202bce80f
|
@ -492,6 +492,11 @@ RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, const CallExpr *E) {
|
|||
else if (hasAggregateLLVMType(E->getType()))
|
||||
// Struct return.
|
||||
return RValue::getAggregate(Args[0]);
|
||||
else {
|
||||
// void return.
|
||||
assert(E->getType()->isVoidType() && "Should only have a void expr here");
|
||||
V = 0;
|
||||
}
|
||||
|
||||
return RValue::get(V);
|
||||
}
|
||||
|
|
|
@ -912,6 +912,11 @@ VisitConditionalOperator(const ConditionalOperator *E) {
|
|||
|
||||
CGF.EmitBlock(ContBlock);
|
||||
|
||||
if (!LHS) {
|
||||
assert(E->getType()->isVoidType() && "Non-void value should have a value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create a PHI node for the real part.
|
||||
llvm::PHINode *PN = Builder.CreatePHI(LHS->getType(), "cond");
|
||||
PN->reserveOperandSpace(2);
|
||||
|
@ -926,16 +931,14 @@ Value *ScalarExprEmitter::VisitChooseExpr(ChooseExpr *E) {
|
|||
Visit(E->isConditionTrue(CGF.getContext()) ? E->getLHS() : E->getRHS());
|
||||
}
|
||||
|
||||
Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE)
|
||||
{
|
||||
Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
|
||||
llvm::Value *ArgValue = EmitLValue(VE->getSubExpr()).getAddress();
|
||||
|
||||
llvm::Value *V = Builder.CreateVAArg(ArgValue, ConvertType(VE->getType()));
|
||||
return V;
|
||||
}
|
||||
|
||||
Value *ScalarExprEmitter::VisitObjCEncodeExpr(const ObjCEncodeExpr *E)
|
||||
{
|
||||
Value *ScalarExprEmitter::VisitObjCEncodeExpr(const ObjCEncodeExpr *E) {
|
||||
std::string str;
|
||||
|
||||
CGF.getContext().getObjcEncodingForType(E->getEncodedType(), str);
|
||||
|
|
|
@ -8,3 +8,10 @@ double test2(int cond, float a, double b)
|
|||
{
|
||||
return cond ? a : b;
|
||||
}
|
||||
|
||||
void f();
|
||||
|
||||
void test3(){
|
||||
1 ? f() : (void)0;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче