Some small fixes for fields of reference type.
llvm-svn: 72636
This commit is contained in:
parent
9499ab3287
commit
f7f9f68722
|
@ -231,7 +231,10 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) {
|
|||
FieldDecl *FD = dyn_cast<FieldDecl>(E->getMemberDecl());
|
||||
if (!FD) // FIXME: deal with other kinds of member expressions
|
||||
return APValue();
|
||||
|
||||
|
||||
if (FD->getType()->isReferenceType())
|
||||
return APValue();
|
||||
|
||||
// FIXME: This is linear time.
|
||||
unsigned i = 0;
|
||||
for (RecordDecl::field_iterator Field = RD->field_begin(Info.Ctx),
|
||||
|
@ -1047,7 +1050,7 @@ unsigned IntExprEvaluator::GetAlignOfType(QualType T) {
|
|||
// Get information about the alignment.
|
||||
unsigned CharSize = Info.Ctx.Target.getCharWidth();
|
||||
|
||||
// FIXME: Why do we ask for the preferred alignment?
|
||||
// __alignof is defined to return the preferred alignment.
|
||||
return Info.Ctx.getPreferredTypeAlign(T.getTypePtr()) / CharSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -1034,6 +1034,8 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
|
|||
llvm::PointerType::get(FieldTy, AS),
|
||||
"tmp");
|
||||
}
|
||||
if (Field->getType()->isReferenceType())
|
||||
V = Builder.CreateLoad(V, "tmp");
|
||||
|
||||
QualType::GCAttrTypes attr = QualType::GCNone;
|
||||
if (CGM.getLangOptions().ObjC1 &&
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: clang-cc -emit-llvm -o - %s -O2 | grep "@_Z1bv"
|
||||
|
||||
// Make sure the call to b() doesn't get optimized out.
|
||||
extern struct x {char& x,y;}y;
|
||||
int b();
|
||||
int a() { if (!&y.x) b(); }
|
Loading…
Reference in New Issue