forked from OSchip/llvm-project
[MS ABI] Initialize "most general" member pointers which don't point at a vbase
The most general model has fields for the vbptr offset and the vbindex. Don't initialize the vbptr offset if the vbindex is 0: we aren't referencing an entity from a vbase. Getting this wrong can make member pointer equality fail. llvm-svn: 240043
This commit is contained in:
parent
ea63a28364
commit
7bd29f2613
|
@ -2351,7 +2351,7 @@ MicrosoftCXXABI::EmitFullMemberPointer(llvm::Constant *FirstField,
|
|||
|
||||
if (MSInheritanceAttr::hasVBPtrOffsetField(Inheritance)) {
|
||||
CharUnits Offs = CharUnits::Zero();
|
||||
if (RD->getNumVBases())
|
||||
if (VBTableIndex && RD->getNumVBases())
|
||||
Offs = getContext().getASTRecordLayout(RD).getVBPtrOffset();
|
||||
fields.push_back(llvm::ConstantInt::get(CGM.IntTy, Offs.getQuantity()));
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ void (UnspecSingle::*us_f_mp)() = &UnspecSingle::foo;
|
|||
// CHECK: @"\01?v_f_mp@Const@@3P8Virtual@@AEXXZQ2@" =
|
||||
// CHECK: global { i8*, i32, i32 } { i8* bitcast ({{.*}} @"\01?foo@Virtual@@QAEXXZ" to i8*), i32 0, i32 0 }, align 4
|
||||
// CHECK: @"\01?u_f_mp@Const@@3P8Unspecified@@AEXXZQ2@" =
|
||||
// CHECK: global { i8*, i32, i32, i32 } { i8* bitcast ({{.*}} @"\01?foo@Unspecified@@QAEXXZ" to i8*), i32 0, i32 12, i32 0 }, align 4
|
||||
// CHECK: global { i8*, i32, i32, i32 } { i8* bitcast ({{.*}} @"\01?foo@Unspecified@@QAEXXZ" to i8*), i32 0, i32 0, i32 0 }, align 4
|
||||
// CHECK: @"\01?us_f_mp@Const@@3P8UnspecSingle@@AEXXZQ2@" =
|
||||
// CHECK: global { i8*, i32, i32, i32 } { i8* bitcast ({{.*}} @"\01?foo@UnspecSingle@@QAEXXZ" to i8*), i32 0, i32 0, i32 0 }, align 4
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue