clang: lib/AST/APValue.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/Support/raw_ostream.h"
23using namespace clang;
24
25
26
28 : T(T->getCanonicalTypeUnqualified().getTypePtr()) {}
29
32 Out << "typeid(";
34 Out << ")";
35}
36
37static_assert(
39 alignof(Type),
40 "Type is insufficiently aligned");
41
46
51 Base.DynamicAllocType = Type.getAsOpaquePtr();
53}
54
59 Base.TypeInfoType = TypeInfo.getAsOpaquePtr();
61}
62
64 if (!*this) return QualType();
65 if (const ValueDecl *D = dyn_cast<const ValueDecl*>()) {
66
67
68
69
70
71
72
74 Redecl = cast_or_null(Redecl->getPreviousDecl())) {
77 return T;
78 }
79 return D->getType();
80 }
81
82 if (is())
83 return getTypeInfoType();
84
85 if (is())
86 return getDynamicAllocType();
87
88 const Expr *Base = get<const Expr*>();
89
90
91
93 llvm::dyn_cast(Base)) {
96 const Expr *Temp = MTE->getSubExpr();
98 Adjustments);
99
100
101 if (!Adjustments.empty())
102 return Inner->getType();
103 }
104
105 return Base->getType();
106}
107
109 return (is() || is()) ? 0
110 : Local.CallIndex;
111}
112
114 return (is() || is()) ? 0 : Local.Version;
115}
116
118 assert(is() && "not a type_info lvalue");
120}
121
123 assert(is() && "not a dynamic allocation lvalue");
125}
126
128 ID.AddPointer(Ptr.getOpaqueValue());
129 if (is() || is())
130 return;
131 ID.AddInteger(Local.CallIndex);
132 ID.AddInteger(Local.Version);
133}
134
138 if (LHS.Ptr != RHS.Ptr)
139 return false;
141 return true;
142 return LHS.Local.CallIndex == RHS.Local.CallIndex &&
143 LHS.Local.Version == RHS.Local.Version;
144}
145}
146
148 if (const Decl *D = BaseOrMember.getPointer())
150 Value = reinterpret_cast<uintptr_t>(BaseOrMember.getOpaqueValue());
151}
152
154 ID.AddInteger(Value);
155}
156
159 : Ty((const void *)ElemTy.getTypePtrOrNull()), Path(Path) {}
160
163}
164
165namespace {
166 struct LVBase {
169 unsigned PathLength;
170 bool IsNullPtr : 1;
171 bool IsOnePastTheEnd : 1;
172 };
173}
174
176 return Ptr.getOpaqueValue();
177}
178
180 return Ptr.isNull();
181}
182
183APValue::LValueBase::operator bool () const {
184 return static_cast<bool>(Ptr);
185}
186
188llvm::DenseMapInfoclang::APValue::LValueBase::getEmptyKey() {
190 B.Ptr = DenseMapInfo<const ValueDecl*>::getEmptyKey();
191 return B;
192}
193
195llvm::DenseMapInfoclang::APValue::LValueBase::getTombstoneKey() {
197 B.Ptr = DenseMapInfo<const ValueDecl*>::getTombstoneKey();
198 return B;
199}
200
205 return llvm::hash_combine(Base.getOpaqueValue(), Base.getCallIndex(),
206 Base.getVersion());
207}
208}
209
210unsigned llvm::DenseMapInfoclang::APValue::LValueBase::getHashValue(
213}
214
215bool llvm::DenseMapInfoclang::APValue::LValueBase::isEqual(
218 return LHS == RHS;
219}
220
222 static const unsigned InlinePathSpace =
224
225
226
227
228 union {
231 };
232
235
237 if (Length == PathLength)
238 return;
239 if (hasPathPtr())
240 delete [] PathPtr;
241 PathLength = Length;
242 if (hasPathPtr())
244 }
245
247 bool hasPathPtr() const { return hasPath() && PathLength > InlinePathSpace; }
248
251 return hasPathPtr() ? PathPtr : Path;
252 }
253};
254
255namespace {
256 struct MemberPointerBase {
257 llvm::PointerIntPair<const ValueDecl*, 1, bool> MemberAndIsDerivedMember;
258 unsigned PathLength;
259 };
260}
261
263 static const unsigned InlinePathSpace =
264 (DataSize - sizeof(MemberPointerBase)) / sizeof(const CXXRecordDecl*);
266 union {
269 };
270
273
275 if (Length == PathLength)
276 return;
277 if (hasPathPtr())
278 delete [] PathPtr;
279 PathLength = Length;
280 if (hasPathPtr())
281 PathPtr = new PathElem[Length];
282 }
283
284 bool hasPathPtr() const { return PathLength > InlinePathSpace; }
285
288 return hasPathPtr() ? PathPtr : Path;
289 }
290};
291
292
293
294APValue::Arr::Arr(unsigned NumElts, unsigned Size) :
295 Elts(new APValue[NumElts + (NumElts != Size ? 1 : 0)]),
296 NumElts(NumElts), ArrSize(Size) {}
297APValue::Arr::~Arr() { delete [] Elts; }
298
299APValue::StructData::StructData(unsigned NumBases, unsigned NumFields) :
300 Elts(new APValue[NumBases+NumFields]),
301 NumBases(NumBases), NumFields(NumFields) {}
302APValue::StructData::~StructData() {
303 delete [] Elts;
304}
305
306APValue::UnionData::UnionData() : Field(nullptr), Value(new APValue) {}
307APValue::UnionData::~UnionData () {
309}
310
312 : Kind(None), AllowConstexprUnknown(RHS.AllowConstexprUnknown) {
317 break;
318 case Int:
319 MakeInt();
321 break;
323 MakeFloat();
325 break;
328 MakeFixedPoint(std::move(FXCopy));
329 break;
330 }
332 MakeVector();
333 setVector(((const Vec *)(const char *)&RHS.Data)->Elts,
335 break;
337 MakeComplexInt();
339 break;
341 MakeComplexFloat();
343 break;
345 MakeLValue();
349 else
352 break;
359 break;
366 break;
368 MakeUnion();
370 break;
375 break;
377 MakeAddrLabelDiff();
379 break;
380 }
381}
382
384 : Kind(RHS.Kind), AllowConstexprUnknown(RHS.AllowConstexprUnknown),
386 RHS.Kind = None;
387}
388
390 if (this != &RHS)
392
393 AllowConstexprUnknown = RHS.AllowConstexprUnknown;
394 return *this;
395}
396
398 if (this != &RHS) {
400 DestroyDataAndMakeUninit();
401 Kind = RHS.Kind;
402 Data = RHS.Data;
403 AllowConstexprUnknown = RHS.AllowConstexprUnknown;
404 RHS.Kind = None;
405 }
406 return *this;
407}
408
409void APValue::DestroyDataAndMakeUninit() {
410 if (Kind == Int)
412 else if (Kind == Float)
413 ((APFloat *)(char *)&Data)->~APFloat();
415 ((APFixedPoint *)(char *)&Data)->~APFixedPoint();
416 else if (Kind == Vector)
417 ((Vec *)(char *)&Data)->~Vec();
419 ((ComplexAPSInt *)(char *)&Data)->~ComplexAPSInt();
421 ((ComplexAPFloat *)(char *)&Data)->~ComplexAPFloat();
422 else if (Kind == LValue)
423 ((LV *)(char *)&Data)->~LV();
424 else if (Kind == Array)
425 ((Arr *)(char *)&Data)->~Arr();
426 else if (Kind == Struct)
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();
435 AllowConstexprUnknown = false;
436}
437
443 return false;
448 return true;
449 case Int:
450 return getInt().needsCleanup();
452 return getFloat().needsCleanup();
454 return getFixedPoint().getValue().needsCleanup();
458 "In _Complex float types, real and imaginary values always have the "
459 "same size.");
464 "In _Complex int types, real and imaginary values must have the "
465 "same size.");
468 return reinterpret_cast<const LV *>(&Data)->hasPathPtr();
470 return reinterpret_cast<const MemberPointerData *>(&Data)->hasPathPtr();
471 }
472 llvm_unreachable("Unknown APValue kind!");
473}
474
476 std::swap(Kind, RHS.Kind);
477 std::swap(Data, RHS.Data);
478
479 bool tmp = AllowConstexprUnknown;
480 AllowConstexprUnknown = RHS.AllowConstexprUnknown;
481 RHS.AllowConstexprUnknown = tmp;
482}
483
484
485static void profileIntValue(llvm::FoldingSetNodeID &ID, const llvm::APInt &V) {
486 for (unsigned I = 0, N = V.getBitWidth(); I < N; I += 32)
487 ID.AddInteger((uint32_t)V.extractBitsAsZExtValue(std::min(32u, N - I), I));
488}
489
491
492
493
494
495
496 ID.AddInteger(Kind);
497
498 switch (Kind) {
501 return;
502
506 return;
507
513 return;
514
517 ID.AddInteger(0);
518 return;
519 }
520 ID.AddInteger(getUnionField()->getFieldIndex() + 1);
522 return;
523
526 return;
527
528
529
530
531
532
533
534
535
536 llvm::FoldingSetNodeID FillerID;
540 ID.AddNodeID(FillerID);
543
544
545
546
547 while (true) {
548 if (N == 0) {
549
551 ID.AddInteger(NumFillers);
552 break;
553 }
554
555
556
558 llvm::FoldingSetNodeID ElemID;
560 if (ElemID != FillerID) {
561 ID.AddInteger(NumFillers);
562 ID.AddNodeID(ElemID);
563 --N;
564 break;
565 }
566 }
567
568
569 ++NumFillers;
570 --N;
571 }
572
573
574 for (; N != 0; --N)
576 return;
577 }
578
582 return;
583
584 case Int:
586 return;
587
590 return;
591
594 return;
595
599 return;
600
604 return;
605
614
615
616
619 }
620 return;
621
626 ID.AddPointer(D);
627 return;
628 }
629
630 llvm_unreachable("Unknown APValue kind!");
631}
632
634 llvm::APFloat V = F;
635 bool ignored;
636 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
637 &ignored);
638 return V.convertToDouble();
639}
640
645 if (Inits.empty())
646 return false;
647
650 return false;
651
652
653 if (!Inits.back().isInt() || !Inits.back().getInt().isZero())
654 return false;
655
656 Inits = Inits.drop_back();
657
659 Buf.push_back('"');
660
661
662 constexpr size_t MaxN = 36;
663 StringRef Ellipsis;
665 Ellipsis = "[...]";
666 Inits =
667 Inits.take_front(std::min(MaxN - Ellipsis.size() / 2, Inits.size()));
668 }
669
670 for (auto &Val : Inits) {
671 if (!Val.isInt())
672 return false;
673 int64_t Char64 = Val.getInt().getExtValue();
675 return false;
676 auto Ch = static_cast<unsigned char>(Char64);
677
678 StringRef Escaped = escapeCStyleEscapeChar::SingleAndDouble(Ch);
679 if (Escaped.empty()) {
681 return false;
682 Buf.emplace_back(Ch);
683 } else {
684 Buf.append(Escaped);
685 }
686 }
687
688 Buf.append(Ellipsis);
689 Buf.push_back('"');
690
692 Out << 'L';
694 Out << "u8";
696 Out << 'u';
698 Out << 'U';
699
700 Out << Buf;
701 return true;
702}
703
707}
708
711
712
714 Out << "void()";
715 return;
716 }
717
719 Ty = AT->getValueType();
720
723 Out << "";
724 return;
726 Out << "";
727 return;
730 Out << (getInt().getBoolValue() ? "true" : "false");
731 else
733 return;
736 return;
739 return;
741 Out << '{';
745 Out << ", ";
747 }
748 Out << '}';
749 return;
750 }
753 return;
757 return;
762 if (InnerTy.isNull())
763 InnerTy = Ty;
764
768 Out << (Policy.Nullptr ? "nullptr" : "0");
769 } else if (IsReference) {
770 Out << "*(" << InnerTy.stream(Policy) << "*)"
772 } else {
773 Out << "(" << Ty.stream(Policy) << ")"
775 }
776 return;
777 }
778
780
786 if (IsReference)
787 Out << "*(";
788 if (S.isZero() || O % S) {
789 Out << "(char*)";
791 }
792 Out << '&';
793 } else if (!IsReference) {
794 Out << '&';
795 }
796
798 Out << *VD;
800 TI.print(Out, Policy);
802 Out << "{*new "
803 << Base.getDynamicAllocType().stream(Policy) << "#"
804 << DA.getIndex() << "}";
805 } else {
806 assert(Base.get<const Expr *>() != nullptr &&
807 "Expecting non-null Expr");
809 }
810
812 Out << " + " << (O / S);
813 if (IsReference)
814 Out << ')';
815 }
816 return;
817 }
818
819
820 if (!IsReference)
821 Out << '&';
823 Out << "*(&";
824
827 Out << *VD;
829 TI.print(Out, Policy);
831 Out << "{*new " << Base.getDynamicAllocType().stream(Policy) << "#"
832 << DA.getIndex() << "}";
833 } else {
835 assert(E != nullptr && "Expecting non-null Expr");
837 }
838
841 for (unsigned I = 0, N = Path.size(); I != N; ++I) {
843
844
845 const Decl *BaseOrMember = Path[I].getAsBaseOrMember().getPointer();
846 if (const CXXRecordDecl *RD = dyn_cast(BaseOrMember)) {
847 CastToBase = RD;
848
849
850 } else {
851 const ValueDecl *VD = cast(BaseOrMember);
852 Out << ".";
853 if (CastToBase)
854 Out << *CastToBase << "::";
855 Out << *VD;
857 }
859
860 Out << (Path[I].getAsArrayIndex() == 0 ? ".real" : ".imag");
862 } else {
863
864 Out << '[' << Path[I].getAsArrayIndex() << ']';
866 }
867 }
868
869
871
872
873 Out << " + 1";
874 if (IsReference)
875 Out << ')';
876 }
877 return;
878 }
884 return;
886 Out << '{';
887 unsigned I = 0;
888 switch (N) {
889 case 0:
890 for (; I != N; ++I) {
891 Out << ", ";
893 Out << "...}";
894 return;
895 }
896 [[fallthrough]];
897 default:
899 }
900 }
901 Out << '}';
902 return;
903 }
905 Out << '{';
907 bool First = true;
909 const CXXRecordDecl *CD = cast(RD);
911 for (unsigned I = 0; I != N; ++I, ++BI) {
914 Out << ", ";
917 }
918 }
919 for (const auto *FI : RD->fields()) {
921 Out << ", ";
922 if (FI->isUnnamedBitField())
923 continue;
925 printPretty(Out, Policy, FI->getType(), Ctx);
927 }
928 Out << '}';
929 return;
930 }
932 Out << '{';
934 Out << "." << *FD << " = ";
936 }
937 Out << '}';
938 return;
940
941
943 Out << '&' << *cast(VD->getDeclContext()) << "::" << *VD;
944 return;
945 }
946 Out << "0";
947 return;
950 Out << " - ";
952 return;
953 }
954 llvm_unreachable("Unknown APValue kind!");
955}
956
959 llvm::raw_string_ostream Out(Result);
962}
963
968 return true;
969 }
970
973 return true;
974 }
975
978 return true;
979 }
980
981 return false;
982}
983
985 assert(isLValue() && "Invalid accessor");
986 return ((const LV *)(const void *)&Data)->Base;
987}
988
990 assert(isLValue() && "Invalid accessor");
991 return ((const LV *)(const void *)&Data)->IsOnePastTheEnd;
992}
993
995 assert(isLValue() && "Invalid accessor");
996 return ((LV *)(void *)&Data)->Offset;
997}
998
1000 assert(isLValue() && "Invalid accessor");
1001 return ((const LV *)(const char *)&Data)->hasPath();
1002}
1003
1006 const LV &LVal = *((const LV *)(const char *)&Data);
1008}
1009
1011 assert(isLValue() && "Invalid accessor");
1012 return ((const LV *)(const char *)&Data)->Base.getCallIndex();
1013}
1014
1016 assert(isLValue() && "Invalid accessor");
1017 return ((const LV *)(const char *)&Data)->Base.getVersion();
1018}
1019
1021 assert(isLValue() && "Invalid usage");
1022 return ((const LV *)(const char *)&Data)->IsNullPtr;
1023}
1024
1026 bool IsNullPtr) {
1027 assert(isLValue() && "Invalid accessor");
1028 LV &LVal = *((LV *)(char *)&Data);
1029 LVal.Base = B;
1030 LVal.IsOnePastTheEnd = false;
1031 LVal.Offset = O;
1033 LVal.IsNullPtr = IsNullPtr;
1034}
1035
1037APValue::setLValueUninit(LValueBase B, const CharUnits &O, unsigned Size,
1038 bool IsOnePastTheEnd, bool IsNullPtr) {
1039 assert(isLValue() && "Invalid accessor");
1040 LV &LVal = *((LV *)(char *)&Data);
1041 LVal.Base = B;
1042 LVal.IsOnePastTheEnd = IsOnePastTheEnd;
1043 LVal.Offset = O;
1044 LVal.IsNullPtr = IsNullPtr;
1045 LVal.resizePath(Size);
1046 return {LVal.getPath(), Size};
1047}
1048
1051 bool IsNullPtr) {
1053 setLValueUninit(B, O, Path.size(), IsOnePastTheEnd, IsNullPtr);
1054 if (Path.size()) {
1055 memcpy(InternalPath.data(), Path.data(),
1057 }
1058}
1059
1061 assert(isUnion() && "Invalid accessor");
1062 ((UnionData *)(char *)&Data)->Field =
1063 Field ? Field->getCanonicalDecl() : nullptr;
1064 *((UnionData *)(char *)&Data)->Value = Value;
1065}
1066
1071 return MPD.MemberAndIsDerivedMember.getPointer();
1072}
1073
1078 return MPD.MemberAndIsDerivedMember.getInt();
1079}
1080
1086}
1087
1088void APValue::MakeLValue() {
1089 assert(isAbsent() && "Bad state change");
1090 static_assert(sizeof(LV) <= DataSize, "LV too big");
1091 new ((void *)(char *)&Data) LV();
1093}
1094
1095void APValue::MakeArray(unsigned InitElts, unsigned Size) {
1096 assert(isAbsent() && "Bad state change");
1097 new ((void *)(char *)&Data) Arr(InitElts, Size);
1099}
1100
1102APValue::setMemberPointerUninit(const ValueDecl *Member, bool IsDerivedMember,
1103 unsigned Size) {
1104 assert(isAbsent() && "Bad state change");
1105 MemberPointerData *MPD = new ((void *)(char *)&Data) MemberPointerData;
1107 MPD->MemberAndIsDerivedMember.setPointer(
1108 Member ? cast(Member->getCanonicalDecl()) : nullptr);
1109 MPD->MemberAndIsDerivedMember.setInt(IsDerivedMember);
1110 MPD->resizePath(Size);
1111 return {MPD->getPath(), MPD->PathLength};
1112}
1113
1114void APValue::MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember,
1117 setMemberPointerUninit(Member, IsDerivedMember, Path.size());
1118 for (unsigned I = 0; I != Path.size(); ++I)
1120}
1121
1125
1126 auto MergeLV = [&](LinkageInfo MergeLV) {
1127 LV.merge(MergeLV);
1129 };
1130 auto Merge = [&](const APValue &V) {
1131 return MergeLV(getLVForValue(V, computation));
1132 };
1133
1134 switch (V.getKind()) {
1143 break;
1144
1146
1147
1149
1151 for (unsigned I = 0, N = V.getStructNumBases(); I != N; ++I)
1152 if (Merge(V.getStructBase(I)))
1153 break;
1154 for (unsigned I = 0, N = V.getStructNumFields(); I != N; ++I)
1155 if (Merge(V.getStructField(I)))
1156 break;
1157 break;
1158 }
1159
1161 if (V.getUnionField())
1162 Merge(V.getUnionValue());
1163 break;
1164
1166 for (unsigned I = 0, N = V.getArrayInitializedElts(); I != N; ++I)
1167 if (Merge(V.getArrayInitializedElt(I)))
1168 break;
1169 if (V.hasArrayFiller())
1170 Merge(V.getArrayFiller());
1171 break;
1172 }
1173
1175 if (.getLValueBase()) {
1176
1177 } else if (const auto *VD =
1178 V.getLValueBase().dyn_cast<const ValueDecl *>()) {
1179 if (VD && MergeLV(getLVForDecl(VD, computation)))
1180 break;
1181 } else if (const auto TI = V.getLValueBase().dyn_cast<TypeInfoLValue>()) {
1182 if (MergeLV(getLVForType(*TI.getType(), computation)))
1183 break;
1184 } else if (const Expr *E = V.getLValueBase().dyn_cast<const Expr *>()) {
1185
1186
1187
1188
1189
1190
1191 auto *MTE = dyn_cast(E);
1194 if (MergeLV(getLVForDecl(MTE->getExtendingDecl(), computation)))
1195 break;
1196 } else {
1198 "unexpected LValueBase kind");
1200 }
1201
1202
1203 break;
1204 }
1205
1207 if (const NamedDecl *D = V.getMemberPointerDecl())
1209
1210
1211
1212 break;
1213 }
1214
1215 return LV;
1216}
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.
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'.
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,...