From 7dfa639e9274b9f40c8f207e35c0fcbfe75d04f8 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 1 Jun 2008 15:31:44 +0000 Subject: Make sure _Bool globals have the correct type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51838 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprConstant.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CGExprConstant.cpp') diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 4cb3c7bb2a..be9eaad9ac 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -793,13 +793,18 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, CodeGenFunction *CGF) { QualType type = E->getType().getCanonicalType(); - + if (type->isIntegerType()) { llvm::APSInt Value(static_cast(Context.getTypeSize(type))); if (E->isIntegerConstantExpr(Value, Context)) { return llvm::ConstantInt::get(Value); } } - - return ConstExprEmitter(*this, CGF).Visit(const_cast(E)); + + llvm::Constant* C = ConstExprEmitter(*this, CGF).Visit(const_cast(E)); + if (C->getType() == llvm::Type::Int1Ty) { + const llvm::Type *BoolTy = getTypes().ConvertTypeForMem(E->getType()); + C = llvm::ConstantExpr::getZExt(C, BoolTy); + } + return C; } -- cgit v1.2.3