aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-05-29 11:33:25 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-05-29 11:33:25 +0000
commit1e86b34f15f0502c13750ee1d6cf338def6e2242 (patch)
tree354eb64d6e241a781217bd73ee90dcfe3c2be5e8 /lib/CodeGen
parentbc5ed6ef52d43b5a3c924421aac3c1f0f829dcc8 (diff)
Rearrange EmitLValueForField a bit to work properly for _Bool bitfields
in unions (we don't want to do the union-specific bitcast for bit-fields). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGExpr.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index d715b45229..f657d8f288 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -557,9 +557,7 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
llvm::Value *V;
unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
- if (!Field->isBitField()) {
- V = Builder.CreateStructGEP(BaseValue, idx, "tmp");
- } else {
+ if (Field->isBitField()) {
// FIXME: CodeGenTypes should expose a method to get the appropriate
// type for FieldTy (the appropriate type is ABI-dependent).
unsigned EltTySize =
@@ -574,8 +572,15 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
V = Builder.CreateGEP(BaseValue,
llvm::ConstantInt::get(llvm::Type::Int32Ty, idx),
"tmp");
+
+ CodeGenTypes::BitFieldInfo bitFieldInfo =
+ CGM.getTypes().getBitFieldInfo(Field);
+ return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size,
+ Field->getType()->isSignedIntegerType());
}
+ V = Builder.CreateStructGEP(BaseValue, idx, "tmp");
+
// Match union field type.
if (isUnion) {
const llvm::Type * FieldTy = ConvertType(Field->getType());
@@ -587,13 +592,7 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
"tmp");
}
- if (!Field->isBitField())
- return LValue::MakeAddr(V);
-
- CodeGenTypes::BitFieldInfo bitFieldInfo =
- CGM.getTypes().getBitFieldInfo(Field);
- return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size,
- Field->getType()->isSignedIntegerType());
+ return LValue::MakeAddr(V);
}
LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr* E) {