From 1274ccd90aec0b205fc838c3d504821ccfb55482 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 8 Oct 2010 23:50:27 +0000 Subject: Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked a bit by me). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116122 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 78c1da5060..e4ed5d64d9 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -599,11 +599,17 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(llvm::Value *Addr, bool Volatile, return V; } +static bool isBooleanUnderlyingType(QualType Ty) { + if (const EnumType *ET = dyn_cast(Ty)) + return ET->getDecl()->getIntegerType()->isBooleanType(); + return false; +} + void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, bool Volatile, unsigned Alignment, QualType Ty) { - if (Ty->isBooleanType()) { + if (Ty->isBooleanType() || isBooleanUnderlyingType(Ty)) { // Bool can have different representation in memory than in registers. const llvm::PointerType *DstPtr = cast(Addr->getType()); Value = Builder.CreateIntCast(Value, DstPtr->getElementType(), false); -- cgit v1.2.3