CharUnits CGCXXABI::getMemberPointerPathAdjustment(const APValue &MP) { // TODO: Store base specifiers in APValue member pointer paths so we can // easily reuse CGM.GetNonVirtualBaseClassOffset(). const ValueDecl *MPD = MP.getMemberPointerDecl(); CharUnits ThisAdjustment = CharUnits::Zero(); ArrayRef<const CXXRecordDecl*> Path = MP.getMemberPointerPath(); bool DerivedMember = MP.isMemberPointerToDerivedMember(); const CXXRecordDecl *RD = cast<CXXRecordDecl>(MPD->getDeclContext()); for (unsigned I = 0, N = Path.size(); I != N; ++I) { const CXXRecordDecl *Base = RD; const CXXRecordDecl *Derived = Path[I]; if (DerivedMember) std::swap(Base, Derived); ThisAdjustment += getContext().getASTRecordLayout(Derived).getBaseClassOffset(Base); RD = Path[I]; } if (DerivedMember) ThisAdjustment = -ThisAdjustment; return ThisAdjustment; }
APValue::APValue(const APValue &RHS) : Kind(Uninitialized) { switch (RHS.getKind()) { case Uninitialized: break; case Int: MakeInt(); setInt(RHS.getInt()); break; case Float: MakeFloat(); setFloat(RHS.getFloat()); break; case Vector: MakeVector(); setVector(((const Vec *)(const char *)RHS.Data.buffer)->Elts, RHS.getVectorLength()); break; case ComplexInt: MakeComplexInt(); setComplexInt(RHS.getComplexIntReal(), RHS.getComplexIntImag()); break; case ComplexFloat: MakeComplexFloat(); setComplexFloat(RHS.getComplexFloatReal(), RHS.getComplexFloatImag()); break; case LValue: MakeLValue(); if (RHS.hasLValuePath()) setLValue(RHS.getLValueBase(), RHS.getLValueOffset(), RHS.getLValuePath(), RHS.isLValueOnePastTheEnd(), RHS.isNullPointer()); else setLValue(RHS.getLValueBase(), RHS.getLValueOffset(), NoLValuePath(), RHS.isNullPointer()); break; case Array: MakeArray(RHS.getArrayInitializedElts(), RHS.getArraySize()); for (unsigned I = 0, N = RHS.getArrayInitializedElts(); I != N; ++I) getArrayInitializedElt(I) = RHS.getArrayInitializedElt(I); if (RHS.hasArrayFiller()) getArrayFiller() = RHS.getArrayFiller(); break; case Struct: MakeStruct(RHS.getStructNumBases(), RHS.getStructNumFields()); for (unsigned I = 0, N = RHS.getStructNumBases(); I != N; ++I) getStructBase(I) = RHS.getStructBase(I); for (unsigned I = 0, N = RHS.getStructNumFields(); I != N; ++I) getStructField(I) = RHS.getStructField(I); break; case Union: MakeUnion(); setUnion(RHS.getUnionField(), RHS.getUnionValue()); break; case MemberPointer: MakeMemberPointer(RHS.getMemberPointerDecl(), RHS.isMemberPointerToDerivedMember(), RHS.getMemberPointerPath()); break; case AddrLabelDiff: MakeAddrLabelDiff(); setAddrLabelDiff(RHS.getAddrLabelDiffLHS(), RHS.getAddrLabelDiffRHS()); break; } }