Lines Matching +full:merge +full:- +full:base

1 //===--- APValue.cpp - Union class for APFloat/APSInt/Complex -------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
28 : T(T->getCanonicalTypeUnqualified().getTypePtr()) {} in TypeInfoLValue()
43 : Ptr(P ? cast<ValueDecl>(P->getCanonicalDecl()) : nullptr), Local{I, V} {} in LValueBase()
49 LValueBase Base; in getDynamicAlloc() local
50 Base.Ptr = LV; in getDynamicAlloc()
51 Base.DynamicAllocType = Type.getAsOpaquePtr(); in getDynamicAlloc()
52 return Base; in getDynamicAlloc()
57 LValueBase Base; in getTypeInfo() local
58 Base.Ptr = LV; in getTypeInfo()
59 Base.TypeInfoType = TypeInfo.getAsOpaquePtr(); in getTypeInfo()
60 return Base; in getTypeInfo()
73 for (auto *Redecl = cast<ValueDecl>(D->getMostRecentDecl()); Redecl; in getType()
74 Redecl = cast_or_null<ValueDecl>(Redecl->getPreviousDecl())) { in getType()
75 QualType T = Redecl->getType(); in getType()
76 if (!T->isIncompleteArrayType()) in getType()
79 return D->getType(); in getType()
88 const Expr *Base = get<const Expr*>(); in getType() local
93 llvm::dyn_cast<MaterializeTemporaryExpr>(Base)) { in getType()
96 const Expr *Temp = MTE->getSubExpr(); in getType()
97 const Expr *Inner = Temp->skipRValueSubobjectAdjustments(CommaLHSs, in getType()
99 // Keep any cv-qualifiers from the reference if we generated a temporary in getType()
102 return Inner->getType(); in getType()
105 return Base->getType(); in getType()
149 BaseOrMember.setPointer(D->getCanonicalDecl()); in LValuePathEntry()
167 APValue::LValueBase Base; member
202 llvm::hash_code hash_value(const APValue::LValueBase &Base) { in hash_value() argument
203 if (Base.is<TypeInfoLValue>() || Base.is<DynamicAllocLValue>()) in hash_value()
204 return llvm::hash_value(Base.getOpaqueValue()); in hash_value()
205 return llvm::hash_combine(Base.getOpaqueValue(), Base.getCallIndex(), in hash_value()
206 Base.getVersion()); in hash_value()
211 const clang::APValue::LValueBase &Base) { in getHashValue() argument
212 return hash_value(Base); in getHashValue()
223 (DataSize - sizeof(LVBase)) / sizeof(LValuePathEntry);
225 /// Path - The sequence of base classes, fields and array indices to follow to
226 /// walk from Base to the subobject. When performing GCC-style folding, there
233 LV() { PathLength = (unsigned)-1; } in LV()
246 bool hasPath() const { return PathLength != (unsigned)-1; } in hasPath()
264 (DataSize - sizeof(MemberPointerBase)) / sizeof(const CXXRecordDecl*);
332 setVector(((const Vec *)(const char *)&RHS.Data)->Elts, in APValue()
405 ((APSInt *)(char *)&Data)->~APSInt(); in DestroyDataAndMakeUninit()
407 ((APFloat *)(char *)&Data)->~APFloat(); in DestroyDataAndMakeUninit()
409 ((APFixedPoint *)(char *)&Data)->~APFixedPoint(); in DestroyDataAndMakeUninit()
411 ((Vec *)(char *)&Data)->~Vec(); in DestroyDataAndMakeUninit()
413 ((ComplexAPSInt *)(char *)&Data)->~ComplexAPSInt(); in DestroyDataAndMakeUninit()
415 ((ComplexAPFloat *)(char *)&Data)->~ComplexAPFloat(); in DestroyDataAndMakeUninit()
417 ((LV *)(char *)&Data)->~LV(); in DestroyDataAndMakeUninit()
419 ((Arr *)(char *)&Data)->~Arr(); in DestroyDataAndMakeUninit()
421 ((StructData *)(char *)&Data)->~StructData(); in DestroyDataAndMakeUninit()
423 ((UnionData *)(char *)&Data)->~UnionData(); in DestroyDataAndMakeUninit()
425 ((MemberPointerData *)(char *)&Data)->~MemberPointerData(); in DestroyDataAndMakeUninit()
427 ((AddrLabelDiffData *)(char *)&Data)->~AddrLabelDiffData(); in DestroyDataAndMakeUninit()
461 return reinterpret_cast<const LV *>(&Data)->hasPathPtr(); in needsCleanup()
463 return reinterpret_cast<const MemberPointerData *>(&Data)->hasPathPtr(); in needsCleanup()
473 /// Profile the value of an APInt, excluding its bit-width.
476 ID.AddInteger((uint32_t)V.extractBitsAsZExtValue(std::min(32u, N - I), I)); in profileIntValue()
493 ID.AddPointer(getAddrLabelDiffLHS()->getLabel()->getCanonicalDecl()); in Profile()
494 ID.AddPointer(getAddrLabelDiffRHS()->getLabel()->getCanonicalDecl()); in Profile()
509 ID.AddInteger(getUnionField()->getFieldIndex() + 1); in Profile()
527 : getArrayInitializedElt(getArrayInitializedElts() - 1)) in Profile()
530 unsigned NumFillers = getArraySize() - getArrayInitializedElts(); in Profile()
548 getArrayInitializedElt(N - 1).Profile(ElemID); in Profile()
552 --N; in Profile()
559 --N; in Profile()
563 for (; N != 0; --N) in Profile()
564 getArrayInitializedElt(N - 1).Profile(ID); in Profile()
637 QualType Ty = ATy->getElementType(); in TryPrintAsStringLiteral()
638 if (!Ty->isAnyCharacterType()) in TryPrintAsStringLiteral()
641 // Nothing we can do about a sequence that is not null-terminated in TryPrintAsStringLiteral()
650 // Better than printing a two-digit sequence of 10 integers. in TryPrintAsStringLiteral()
656 Inits.take_front(std::min(MaxN - Ellipsis.size() / 2, Inits.size())); in TryPrintAsStringLiteral()
680 if (Ty->isWideCharType()) in TryPrintAsStringLiteral()
682 else if (Ty->isChar8Type()) in TryPrintAsStringLiteral()
684 else if (Ty->isChar16Type()) in TryPrintAsStringLiteral()
686 else if (Ty->isChar32Type()) in TryPrintAsStringLiteral()
702 if (Ty->isVoidType()) { in printPretty()
707 if (const auto *AT = Ty->getAs<AtomicType>()) in printPretty()
708 Ty = AT->getValueType(); in printPretty()
718 if (Ty->isBooleanType()) in printPretty()
731 QualType ElemTy = Ty->castAs<VectorType>()->getElementType(); in printPretty()
748 bool IsReference = Ty->isReferenceType(); in printPretty()
750 = IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType(); in printPretty()
754 LValueBase Base = getLValueBase(); in printPretty() local
755 if (!Base) { in printPretty()
771 CharUnits S = Ctx ? Ctx->getTypeSizeInCharsIfKnown(InnerTy).value_or( in printPretty()
786 if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) in printPretty()
788 else if (TypeInfoLValue TI = Base.dyn_cast<TypeInfoLValue>()) { in printPretty()
790 } else if (DynamicAllocLValue DA = Base.dyn_cast<DynamicAllocLValue>()) { in printPretty()
792 << Base.getDynamicAllocType().stream(Policy) << "#" in printPretty()
795 assert(Base.get<const Expr *>() != nullptr && in printPretty()
796 "Expecting non-null Expr"); in printPretty()
797 Base.get<const Expr*>()->printPretty(Out, nullptr, Policy); in printPretty()
814 QualType ElemTy = Base.getType(); in printPretty()
815 if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) { in printPretty()
817 } else if (TypeInfoLValue TI = Base.dyn_cast<TypeInfoLValue>()) { in printPretty()
819 } else if (DynamicAllocLValue DA = Base.dyn_cast<DynamicAllocLValue>()) { in printPretty()
820 Out << "{*new " << Base.getDynamicAllocType().stream(Policy) << "#" in printPretty()
823 const Expr *E = Base.get<const Expr*>(); in printPretty()
824 assert(E != nullptr && "Expecting non-null Expr"); in printPretty()
825 E->printPretty(Out, nullptr, Policy); in printPretty()
831 if (ElemTy->isRecordType()) { in printPretty()
832 // The lvalue refers to a class type, so the next path entry is a base in printPretty()
837 // Leave ElemTy referring to the most-derived class. The actual type in printPretty()
845 ElemTy = VD->getType(); in printPretty()
847 } else if (ElemTy->isAnyComplexType()) { in printPretty()
850 ElemTy = ElemTy->castAs<ComplexType>()->getElementType(); in printPretty()
854 ElemTy = ElemTy->castAsArrayTypeUnsafe()->getElementType(); in printPretty()
858 // Handle formatting of one-past-the-end lvalues. in printPretty()
860 // FIXME: If CastToBase is non-0, we should prefix the output with in printPretty()
869 const ArrayType *AT = Ty->castAsArrayTypeUnsafe(); in printPretty()
874 QualType ElemTy = AT->getElementType(); in printPretty()
895 const RecordDecl *RD = Ty->castAs<RecordType>()->getDecl(); in printPretty()
899 CXXRecordDecl::base_class_const_iterator BI = CD->bases_begin(); in printPretty()
901 assert(BI != CD->bases_end()); in printPretty()
904 getStructBase(I).printPretty(Out, Policy, BI->getType(), Ctx); in printPretty()
908 for (const auto *FI : RD->fields()) { in printPretty()
911 if (FI->isUnnamedBitField()) in printPretty()
913 getStructField(FI->getFieldIndex()). in printPretty()
914 printPretty(Out, Policy, FI->getType(), Ctx); in printPretty()
924 getUnionValue().printPretty(Out, Policy, FD->getType(), Ctx); in printPretty()
930 // multiple-inheritance scenario. in printPretty()
932 Out << '&' << *cast<CXXRecordDecl>(VD->getDeclContext()) << "::" << *VD; in printPretty()
938 Out << "&&" << getAddrLabelDiffLHS()->getLabel()->getName(); in printPretty()
939 Out << " - "; in printPretty()
940 Out << "&&" << getAddrLabelDiffRHS()->getLabel()->getName(); in printPretty()
976 return ((const LV *)(const void *)&Data)->Base; in getLValueBase()
981 return ((const LV *)(const void *)&Data)->IsOnePastTheEnd; in isLValueOnePastTheEnd()
986 return ((LV *)(void *)&Data)->Offset; in getLValueOffset()
991 return ((const LV *)(const char *)&Data)->hasPath(); in hasLValuePath()
1002 return ((const LV *)(const char *)&Data)->Base.getCallIndex(); in getLValueCallIndex()
1007 return ((const LV *)(const char *)&Data)->Base.getVersion(); in getLValueVersion()
1012 return ((const LV *)(const char *)&Data)->IsNullPtr; in isNullPointer()
1019 LVal.Base = B; in setLValue()
1022 LVal.resizePath((unsigned)-1); in setLValue()
1031 LVal.Base = B; in setLValueUninit()
1052 ((UnionData *)(char *)&Data)->Field = in setUnion()
1053 Field ? Field->getCanonicalDecl() : nullptr; in setUnion()
1054 *((UnionData *)(char *)&Data)->Value = Value; in setUnion()
1101 MPD->MemberAndIsDerivedMember.setPointer( in setMemberPointerUninit()
1102 Member ? cast<ValueDecl>(Member->getCanonicalDecl()) : nullptr); in setMemberPointerUninit()
1103 MPD->MemberAndIsDerivedMember.setInt(IsDerivedMember); in setMemberPointerUninit()
1104 MPD->resizePath(Size); in setMemberPointerUninit()
1105 return {MPD->getPath(), MPD->PathLength}; in setMemberPointerUninit()
1113 InternalPath[I] = Path[I]->getCanonicalDecl(); in MakeMemberPointer()
1121 LV.merge(MergeLV); in getLVForValue()
1124 auto Merge = [&](const APValue &V) { in getLVForValue() local
1146 if (Merge(V.getStructBase(I))) in getLVForValue()
1149 if (Merge(V.getStructField(I))) in getLVForValue()
1156 Merge(V.getUnionValue()); in getLVForValue()
1161 if (Merge(V.getArrayInitializedElt(I))) in getLVForValue()
1164 Merge(V.getArrayFiller()); in getLVForValue()
1180 // lifetime-extended temporaries. in getLVForValue()
1182 // LifetimeExtendedTemporaryDecl itself as the base. in getLVForValue()
1183 // FIXME: If we permit Objective-C object literals in template arguments, in getLVForValue()
1186 if (!MTE || MTE->getStorageDuration() == SD_FullExpression) in getLVForValue()
1188 if (MergeLV(getLVForDecl(MTE->getExtendingDecl(), computation))) in getLVForValue()
1203 // Note that we could have a base-to-derived conversion here to a member of in getLVForValue()