summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-08 23:50:27 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-08 23:50:27 +0000
commit1274ccd90aec0b205fc838c3d504821ccfb55482 (patch)
tree209ddeed0149062574d71825566c959c214ffa39 /lib/CodeGen/CGExpr.cpp
parent258bcbc1474b47b5bd349a438786010fd60e9a0d (diff)
downloadclang-1274ccd90aec0b205fc838c3d504821ccfb55482.tar.gz
clang-1274ccd90aec0b205fc838c3d504821ccfb55482.tar.bz2
clang-1274ccd90aec0b205fc838c3d504821ccfb55482.tar.xz
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
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r--lib/CodeGen/CGExpr.cpp8
1 files changed, 7 insertions, 1 deletions
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<EnumType>(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<llvm::PointerType>(Addr->getType());
Value = Builder.CreateIntCast(Value, DstPtr->getElementType(), false);