;
28:
T(
T->getCanonicalTypeUnqualified().getTypePtr()) {}
40 "Type is insufficiently aligned");
45: Ptr(
P), Local{I,
V} {}
51 Base.DynamicAllocType =
Type.getAsOpaquePtr();
65 if(
const ValueDecl*
D= dyn_cast<const ValueDecl*>()) {
74Redecl = cast_or_null<ValueDecl>(Redecl->getPreviousDecl())) {
82 if(is<TypeInfoLValue>())
83 returngetTypeInfoType();
85 if(is<DynamicAllocLValue>())
86 returngetDynamicAllocType();
88 const Expr*
Base= get<const Expr*>();
93llvm::dyn_cast<MaterializeTemporaryExpr>(
Base)) {
96 const Expr*Temp = MTE->getSubExpr();
101 if(!Adjustments.empty())
102 returnInner->getType();
105 return Base->getType();
109 return(is<TypeInfoLValue>() || is<DynamicAllocLValue>()) ? 0
114 return(is<TypeInfoLValue>() || is<DynamicAllocLValue>()) ? 0 : Local.Version;
118assert(is<TypeInfoLValue>() &&
"not a type_info lvalue");
123assert(is<DynamicAllocLValue>() &&
"not a dynamic allocation lvalue");
128ID.AddPointer(Ptr.getOpaqueValue());
129 if(is<TypeInfoLValue>() || is<DynamicAllocLValue>())
131ID.AddInteger(Local.CallIndex);
132ID.AddInteger(Local.Version);
138 if(LHS.Ptr != RHS.Ptr)
142 returnLHS.
Local.CallIndex == RHS.
Local.CallIndex &&
148 if(
const Decl*
D= BaseOrMember.getPointer())
150 Value=
reinterpret_cast<uintptr_t>(BaseOrMember.getOpaqueValue());
154ID.AddInteger(
Value);
159: Ty((const void *)ElemTy.getTypePtrOrNull()),
Path(
Path) {}
171 boolIsOnePastTheEnd : 1;
176 returnPtr.getOpaqueValue();
183APValue::LValueBase::operator
bool()
const{
184 return static_cast<bool>(Ptr);
188llvm::DenseMapInfo<clang::APValue::LValueBase>::getEmptyKey() {
190B.Ptr = DenseMapInfo<const ValueDecl*>::getEmptyKey();
195llvm::DenseMapInfo<clang::APValue::LValueBase>::getTombstoneKey() {
197B.Ptr = DenseMapInfo<const ValueDecl*>::getTombstoneKey();
205 returnllvm::hash_combine(
Base.getOpaqueValue(),
Base.getCallIndex(),
210unsignedllvm::DenseMapInfo<clang::APValue::LValueBase>::getHashValue(
215boolllvm::DenseMapInfo<clang::APValue::LValueBase>::isEqual(
222 static const unsignedInlinePathSpace =
237 if(Length == PathLength)
247 bool hasPathPtr()
const{
returnhasPath() && PathLength > InlinePathSpace; }
251 returnhasPathPtr() ? PathPtr :
Path;
256 structMemberPointerBase {
257llvm::PointerIntPair<const ValueDecl*, 1, bool> MemberAndIsDerivedMember;
263 static const unsignedInlinePathSpace =
264(DataSize -
sizeof(MemberPointerBase)) /
sizeof(
const CXXRecordDecl*);
275 if(Length == PathLength)
284 bool hasPathPtr()
const{
returnPathLength > InlinePathSpace; }
288 returnhasPathPtr() ? PathPtr :
Path;
294APValue::Arr::Arr(
unsignedNumElts,
unsignedSize) :
295Elts(new
APValue[NumElts + (NumElts != Size ? 1 : 0)]),
296NumElts(NumElts), ArrSize(Size) {}
297APValue::Arr::~Arr() {
delete[] Elts; }
299APValue::StructData::StructData(
unsignedNumBases,
unsignedNumFields) :
300Elts(new
APValue[NumBases+NumFields]),
301NumBases(NumBases), NumFields(NumFields) {}
302APValue::StructData::~StructData() {
307APValue::UnionData::~UnionData () {
312: Kind(
None), AllowConstexprUnknown(RHS.AllowConstexprUnknown) {
328MakeFixedPoint(std::move(FXCopy));
333 setVector(((
constVec *)(
const char*)&RHS.Data)->Elts,
384: Kind(RHS.Kind), AllowConstexprUnknown(RHS.AllowConstexprUnknown),
393AllowConstexprUnknown = RHS.AllowConstexprUnknown;
400DestroyDataAndMakeUninit();
403AllowConstexprUnknown = RHS.AllowConstexprUnknown;
409voidAPValue::DestroyDataAndMakeUninit() {
412 else if(Kind ==
Float)
413((APFloat *)(
char*)&Data)->~APFloat();
415((APFixedPoint *)(
char*)&Data)->~APFixedPoint();
417((Vec *)(
char*)&Data)->~Vec();
419((ComplexAPSInt *)(
char*)&Data)->~ComplexAPSInt();
421((ComplexAPFloat *)(
char*)&Data)->~ComplexAPFloat();
423((LV *)(
char*)&Data)->~LV();
424 else if(Kind ==
Array)
425((Arr *)(
char*)&Data)->~Arr();
427((StructData *)(
char*)&Data)->~StructData();
428 else if(Kind ==
Union)
429((UnionData *)(
char*)&Data)->~UnionData();
431((MemberPointerData *)(
char*)&Data)->~MemberPointerData();
433((AddrLabelDiffData *)(
char*)&Data)->~AddrLabelDiffData();
435AllowConstexprUnknown =
false;
450 return getInt().needsCleanup();
458 "In _Complex float types, real and imaginary values always have the " 464 "In _Complex int types, real and imaginary values must have the " 468 return reinterpret_cast<const LV*
>(&Data)->hasPathPtr();
472llvm_unreachable(
"Unknown APValue kind!");
476std::swap(Kind, RHS.Kind);
477std::swap(Data, RHS.Data);
479 booltmp = AllowConstexprUnknown;
480AllowConstexprUnknown = RHS.AllowConstexprUnknown;
481RHS.AllowConstexprUnknown = tmp;
486 for(
unsignedI = 0, N =
V.getBitWidth(); I < N; I += 32)
487ID.AddInteger((uint32_t)
V.extractBitsAsZExtValue(std::min(32u, N - I), I));
536llvm::FoldingSetNodeID FillerID;
540ID.AddNodeID(FillerID);
551ID.AddInteger(NumFillers);
558llvm::FoldingSetNodeID ElemID;
560 if(ElemID != FillerID) {
561ID.AddInteger(NumFillers);
562ID.AddNodeID(ElemID);
630llvm_unreachable(
"Unknown APValue kind!");
636 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
638 return V.convertToDouble();
653 if(!Inits.back().isInt() || !Inits.back().getInt().isZero())
656Inits = Inits.drop_back();
659Buf.push_back(
'"');
662 constexpr size_tMaxN = 36;
667Inits.take_front(std::min(MaxN - Ellipsis.size() / 2, Inits.size()));
670 for(
auto&Val : Inits) {
673int64_t Char64 = Val.getInt().getExtValue();
676 autoCh =
static_cast<unsigned char>(Char64);
678StringRef Escaped = escapeCStyle<EscapeChar::SingleAndDouble>(Ch);
679 if(Escaped.empty()) {
682Buf.emplace_back(Ch);
688Buf.append(Ellipsis);
689Buf.push_back(
'"');
719Ty = AT->getValueType();
723Out <<
"<out of lifetime>";
726Out <<
"<uninitialized>";
730Out << (
getInt().getBoolValue() ?
"true":
"false");
768Out << (Policy.
Nullptr?
"nullptr":
"0");
769}
else if(IsReference) {
770Out <<
"*("<< InnerTy.
stream(Policy) <<
"*)" 773Out <<
"("<< Ty.
stream(Policy) <<
")" 788 if(S.isZero() || O % S) {
793}
else if(!IsReference) {
800TI.print(Out, Policy);
803<<
Base.getDynamicAllocType().stream(Policy) <<
"#" 804<< DA.getIndex() <<
"}";
806assert(
Base.get<
const Expr*>() !=
nullptr&&
807 "Expecting non-null Expr");
812Out <<
" + "<< (O / S);
829TI.print(Out, Policy);
831Out <<
"{*new "<<
Base.getDynamicAllocType().stream(Policy) <<
"#" 832<< DA.getIndex() <<
"}";
835assert(
E!=
nullptr&&
"Expecting non-null Expr");
841 for(
unsignedI = 0, N =
Path.size(); I != N; ++I) {
845 const Decl*BaseOrMember =
Path[I].getAsBaseOrMember().getPointer();
846 if(
const CXXRecordDecl*RD = dyn_cast<CXXRecordDecl>(BaseOrMember)) {
851 const ValueDecl*VD = cast<ValueDecl>(BaseOrMember);
854Out << *CastToBase <<
"::";
860Out << (
Path[I].getAsArrayIndex() == 0 ?
".real":
".imag");
864Out <<
'['<<
Path[I].getAsArrayIndex() <<
']';
890 for(; I != N; ++I) {
911 for(
unsignedI = 0; I != N; ++I, ++BI) {
919 for(
const auto*FI : RD->
fields()) {
922 if(FI->isUnnamedBitField())
934Out <<
"."<< *FD <<
" = ";
943Out << '&' << *cast<CXXRecordDecl>(VD->getDeclContext()) <<
"::"<< *VD;
954llvm_unreachable(
"Unknown APValue kind!");
959llvm::raw_string_ostream Out(
Result);
985assert(
isLValue() &&
"Invalid accessor");
986 return((
const LV*)(
const void*)&Data)->Base;
990assert(
isLValue() &&
"Invalid accessor");
991 return((
const LV*)(
const void*)&Data)->IsOnePastTheEnd;
995assert(
isLValue() &&
"Invalid accessor");
996 return((
LV*)(
void*)&Data)->Offset;
1000assert(
isLValue() &&
"Invalid accessor");
1001 return((
const LV*)(
const char*)&Data)->hasPath();
1006 const LV&LVal = *((
const LV*)(
const char*)&Data);
1011assert(
isLValue() &&
"Invalid accessor");
1012 return((
const LV*)(
const char*)&Data)->Base.getCallIndex();
1016assert(
isLValue() &&
"Invalid accessor");
1017 return((
const LV*)(
const char*)&Data)->Base.getVersion();
1021assert(
isLValue() &&
"Invalid usage");
1022 return((
const LV*)(
const char*)&Data)->IsNullPtr;
1027assert(
isLValue() &&
"Invalid accessor");
1028 LV&LVal = *((
LV*)(
char*)&Data);
1030LVal.IsOnePastTheEnd =
false;
1033LVal.IsNullPtr = IsNullPtr;
1037APValue::setLValueUninit(LValueBase B,
const CharUnits&O,
unsignedSize,
1038 boolIsOnePastTheEnd,
boolIsNullPtr) {
1039assert(
isLValue() &&
"Invalid accessor");
1040LV &LVal = *((LV *)(
char*)&Data);
1042LVal.IsOnePastTheEnd = IsOnePastTheEnd;
1044LVal.IsNullPtr = IsNullPtr;
1045LVal.resizePath(Size);
1046 return{LVal.getPath(), Size};
1053setLValueUninit(B, O,
Path.size(), IsOnePastTheEnd, IsNullPtr);
1054 if(
Path.size()) {
1061assert(
isUnion() &&
"Invalid accessor");
1062((UnionData *)(
char*)&Data)->Field =
1063Field ? Field->getCanonicalDecl() :
nullptr;
1064*((UnionData *)(
char*)&Data)->
Value=
Value;
1071 returnMPD.MemberAndIsDerivedMember.getPointer();
1078 returnMPD.MemberAndIsDerivedMember.getInt();
1088voidAPValue::MakeLValue() {
1089assert(
isAbsent() &&
"Bad state change");
1090 static_assert(
sizeof(LV) <= DataSize,
"LV too big");
1091 new((
void*)(
char*)&Data) LV();
1095voidAPValue::MakeArray(
unsignedInitElts,
unsignedSize) {
1096assert(
isAbsent() &&
"Bad state change");
1097 new((
void*)(
char*)&Data) Arr(InitElts, Size);
1102APValue::setMemberPointerUninit(
const ValueDecl*
Member,
boolIsDerivedMember,
1104assert(
isAbsent() &&
"Bad state change");
1105MemberPointerData *MPD =
new((
void*)(
char*)&Data) MemberPointerData;
1107MPD->MemberAndIsDerivedMember.setPointer(
1108 Member? cast<ValueDecl>(
Member->getCanonicalDecl()) :
nullptr);
1109MPD->MemberAndIsDerivedMember.setInt(IsDerivedMember);
1110MPD->resizePath(Size);
1111 return{MPD->getPath(), MPD->PathLength};
1114voidAPValue::MakeMemberPointer(
const ValueDecl*
Member,
boolIsDerivedMember,
1117setMemberPointerUninit(
Member, IsDerivedMember,
Path.size());
1118 for(
unsignedI = 0; I !=
Path.size(); ++I)
1127LV.
merge(MergeLV);
1130 autoMerge = [&](
const APValue&
V) {
1131 returnMergeLV(getLVForValue(
V, computation));
1134 switch(
V.getKind()) {
1151 for(
unsignedI = 0, N =
V.getStructNumBases(); I != N; ++I)
1152 if(Merge(
V.getStructBase(I)))
1154 for(
unsignedI = 0, N =
V.getStructNumFields(); I != N; ++I)
1155 if(Merge(
V.getStructField(I)))
1161 if(
V.getUnionField())
1162Merge(
V.getUnionValue());
1166 for(
unsignedI = 0, N =
V.getArrayInitializedElts(); I != N; ++I)
1167 if(Merge(
V.getArrayInitializedElt(I)))
1169 if(
V.hasArrayFiller())
1170Merge(
V.getArrayFiller());
1175 if(!
V.getLValueBase()) {
1177}
else if(
const auto*VD =
1178 V.getLValueBase().dyn_cast<
const ValueDecl*>()) {
1181}
else if(
const autoTI =
V.getLValueBase().dyn_cast<
TypeInfoLValue>()) {
1182 if(MergeLV(getLVForType(*TI.getType(), computation)))
1184}
else if(
const Expr*
E=
V.getLValueBase().dyn_cast<
const Expr*>()) {
1191 auto*MTE = dyn_cast<MaterializeTemporaryExpr>(
E);
1194 if(MergeLV(
getLVForDecl(MTE->getExtendingDecl(), computation)))
1198 "unexpected LValueBase kind");
1207 if(
const NamedDecl*
D=
V.getMemberPointerDecl())
static double GetApproxValue(const llvm::APFloat &F)
static void profileIntValue(llvm::FoldingSetNodeID &ID, const llvm::APInt &V)
Profile the value of an APInt, excluding its bit-width.
static bool TryPrintAsStringLiteral(raw_ostream &Out, const PrintingPolicy &Policy, const ArrayType *ATy, ArrayRef< APValue > Inits)
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static const Decl * getCanonicalDecl(const Decl *D)
C Language Family Type Representation.
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
void Profile(llvm::FoldingSetNodeID &ID) const
unsigned getVersion() const
QualType getDynamicAllocType() const
QualType getTypeInfoType() const
static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo)
static LValueBase getDynamicAlloc(DynamicAllocLValue LV, QualType Type)
void * getOpaqueValue() const
unsigned getCallIndex() const
A non-discriminated union of a base, field, or array index.
void Profile(llvm::FoldingSetNodeID &ID) const
LValuePathSerializationHelper(ArrayRef< LValuePathEntry >, QualType)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool hasArrayFiller() const
const LValueBase getLValueBase() const
APValue & getArrayInitializedElt(unsigned I)
ArrayRef< LValuePathEntry > getLValuePath() const
void swap(APValue &RHS)
Swaps the contents of this and the given APValue.
APValue & getStructField(unsigned i)
const FieldDecl * getUnionField() const
APSInt & getComplexIntImag()
unsigned getStructNumFields() const
llvm::PointerIntPair< const Decl *, 1, bool > BaseOrMemberType
A FieldDecl or CXXRecordDecl, along with a flag indicating whether we mean a virtual or non-virtual b...
ValueKind getKind() const
bool isLValueOnePastTheEnd() const
unsigned getLValueVersion() const
bool isMemberPointerToDerivedMember() const
unsigned getArrayInitializedElts() const
void setComplexInt(APSInt R, APSInt I)
void Profile(llvm::FoldingSetNodeID &ID) const
profile this value.
unsigned getStructNumBases() const
APFixedPoint & getFixedPoint()
bool needsCleanup() const
Returns whether the object performed allocations.
bool hasLValuePath() const
const ValueDecl * getMemberPointerDecl() const
APValue & getUnionValue()
const AddrLabelExpr * getAddrLabelDiffRHS() const
CharUnits & getLValueOffset()
void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const
void setAddrLabelDiff(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
void setComplexFloat(APFloat R, APFloat I)
APValue & getVectorElt(unsigned I)
APValue & getArrayFiller()
unsigned getVectorLength() const
void setUnion(const FieldDecl *Field, const APValue &Value)
void setLValue(LValueBase B, const CharUnits &O, NoLValuePath, bool IsNullPtr)
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
bool isMemberPointer() const
unsigned getArraySize() const
bool toIntegralConstant(APSInt &Result, QualType SrcTy, const ASTContext &Ctx) const
Try to convert this value to an integral constant.
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
APValue & operator=(const APValue &RHS)
unsigned getLValueCallIndex() const
void setVector(const APValue *E, unsigned N)
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
APSInt & getComplexIntReal()
APFloat & getComplexFloatImag()
APFloat & getComplexFloatReal()
APValue & getStructBase(unsigned i)
const AddrLabelExpr * getAddrLabelDiffLHS() const
APValue()
Creates an empty APValue of type None.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
const clang::PrintingPolicy & getPrintingPolicy() const
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type.
std::optional< CharUnits > getTypeSizeInCharsIfKnown(QualType Ty) const
LabelDecl * getLabel() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Represents a base class of a C++ class.
QualType getType() const
Retrieves the type of the base class.
Represents a C++ struct/union/class.
base_class_iterator bases_end()
base_class_iterator bases_begin()
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits One()
One - Construct a CharUnits quantity of one.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Complex values, per C99 6.2.5p11.
Decl - This represents one declaration (or definition), e.g.
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Symbolic representation of a dynamic allocation.
This represents one expression.
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
Represents a member of a struct/union/class.
LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)
getLVForDecl - Get the linkage and visibility for the given declaration.
static LinkageInfo external()
Linkage getLinkage() const
static LinkageInfo internal()
void merge(LinkageInfo other)
Merge both linkage and visibility.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static QualType getFromOpaquePtr(const void *Ptr)
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Represents a struct/union/class.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
Symbolic representation of typeid(T) for some type T.
const Type * getType() const
void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) const
The base class of the type hierarchy.
bool isBooleanType() const
bool isIncompleteArrayType() const
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isChar16Type() const
bool isAnyComplexType() const
bool isChar32Type() const
bool isWideCharType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a GCC generic vector type.
The JSON file list parser is used to communicate input to InstallAPI.
LLVM_READNONE bool isASCII(char c)
Returns true if a byte is an ASCII character.
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ SD_FullExpression
Full-expression storage duration (for temporaries).
@ Result
The result type of a method or function.
llvm::hash_code hash_value(const CustomizableOptional< T > &O)
const FunctionProtoType * T
U cast(CodeGen::Address addr)
hash_code hash_value(const clang::tooling::dependencies::ModuleID &ID)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
void resizePath(unsigned Length)
LValuePathEntry * PathPtr
const LValuePathEntry * getPath() const
LValuePathEntry * getPath()
const CXXRecordDecl * PathElem
void resizePath(unsigned Length)
const PathElem * getPath() const
Describes how types, statements, expressions, and declarations should be printed.
unsigned Nullptr
Whether we should use 'nullptr' rather than '0' as a null pointer constant.
unsigned EntireContentsOfLargeArray
Whether to print the entire array initializers, especially on non-type template parameters,...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4