static void WriteShortAPValueToStream(raw_ostream& Out, const APValue& V) { switch (V.getKind()) { default: llvm_unreachable("Unknown APValue kind!"); case APValue::Uninitialized: Out << "Uninitialized"; break; case APValue::Int: Out << V.getInt(); break; case APValue::Float: Out << GetApproxValue(V.getFloat()); break; case APValue::Vector: Out << '['; WriteShortAPValueToStream(Out, V.getVectorElt(0)); for (unsigned i = 1; i != V.getVectorLength(); ++i) { Out << ", "; WriteShortAPValueToStream(Out, V.getVectorElt(i)); } Out << ']'; break; case APValue::ComplexInt: Out << V.getComplexIntReal() << "+" << V.getComplexIntImag() << "i"; break; case APValue::ComplexFloat: Out << GetApproxValue(V.getComplexFloatReal()) << "+" << GetApproxValue(V.getComplexFloatImag()) << "i"; break; case APValue::LValue: Out << "LValue: <todo>"; break; } }
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; } }