forked from OSchip/llvm-project
Do not walk through member-accesses on bitfields when looking for the object
which is lifetime-extended by a reference binding. An additional temporary is created for such a bitfield access (although we have no explicit AST representation for it). llvm-svn: 183095
This commit is contained in:
parent
f80d72f149
commit
2d18790b3a
|
@ -76,11 +76,13 @@ const Expr *Expr::skipRValueSubobjectAdjustments(
|
|||
if (!ME->isArrow() && ME->getBase()->isRValue()) {
|
||||
assert(ME->getBase()->getType()->isRecordType());
|
||||
if (FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
|
||||
if (!Field->isBitField()) {
|
||||
E = ME->getBase();
|
||||
Adjustments.push_back(SubobjectAdjustment(Field));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
|
||||
if (BO->isPtrMemOp()) {
|
||||
assert(BO->getRHS()->isRValue());
|
||||
|
|
|
@ -604,3 +604,15 @@ namespace BindToSubobject {
|
|||
// CHECK: store i32* {{.*}}, i32** @_ZN15BindToSubobject1dE, align 8
|
||||
int &&d = (B().a).*h();
|
||||
}
|
||||
|
||||
namespace Bitfield {
|
||||
struct S { int a : 5; ~S(); };
|
||||
|
||||
// Do not lifetime extend the S() temporary here.
|
||||
// CHECK: alloca
|
||||
// CHECK: call {{.*}}memset
|
||||
// CHECK: store i32 {{.*}}, i32* @_ZGRN8Bitfield1rE, align 4
|
||||
// CHECK: call void @_ZN8Bitfield1SD1
|
||||
// CHECK: store i32* @_ZGRN8Bitfield1rE, i32** @_ZN8Bitfield1rE, align 8
|
||||
int &&r = S().a;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue