clang 19.0.0git
APValue.h
Go to the documentation of this file.
1//===--- APValue.h - Union class for APFloat/APSInt/Complex -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the APValue class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_APVALUE_H
14#define LLVM_CLANG_AST_APVALUE_H
15
16#include "clang/Basic/LLVM.h"
17#include "llvm/ADT/APFixedPoint.h"
18#include "llvm/ADT/APFloat.h"
19#include "llvm/ADT/APSInt.h"
20#include "llvm/ADT/FoldingSet.h"
21#include "llvm/ADT/PointerIntPair.h"
22#include "llvm/ADT/PointerUnion.h"
23#include "llvm/Support/AlignOf.h"
24
25namespace clang {
26namespace serialization {
27template <typename T> class BasicReaderBase;
28} // end namespace serialization
29
30 class AddrLabelExpr;
31 class ASTContext;
32 class CharUnits;
33 class CXXRecordDecl;
34 class Decl;
36 class Expr;
37 class FieldDecl;
38 struct PrintingPolicy;
39 class Type;
40 class ValueDecl;
41 class QualType;
42
43/// Symbolic representation of typeid(T) for some type T.
45 const Type *T;
46
47public:
49 explicit TypeInfoLValue(const Type *T);
50
51 const Type *getType() const { return T; }
52 explicit operator bool() const { return T; }
53
54 void *getOpaqueValue() { return const_cast<Type*>(T); }
57 V.T = reinterpret_cast<const Type*>(Value);
58 return V;
59 }
60
61 void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) const;
62};
63
64/// Symbolic representation of a dynamic allocation.
66 unsigned Index;
67
68public:
69 DynamicAllocLValue() : Index(0) {}
70 explicit DynamicAllocLValue(unsigned Index) : Index(Index + 1) {}
71 unsigned getIndex() { return Index - 1; }
72
73 explicit operator bool() const { return Index != 0; }
74
76 return reinterpret_cast<void *>(static_cast<uintptr_t>(Index)
78 }
81 V.Index = reinterpret_cast<uintptr_t>(Value) >> NumLowBitsAvailable;
82 return V;
83 }
84
85 static unsigned getMaxIndex() {
86 return (std::numeric_limits<unsigned>::max() >> NumLowBitsAvailable) - 1;
87 }
88
89 static constexpr int NumLowBitsAvailable = 3;
90};
91}
92
93namespace llvm {
94template<> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
96 return V.getOpaqueValue();
97 }
100 }
101 // Validated by static_assert in APValue.cpp; hardcoded to avoid needing
102 // to include Type.h.
103 static constexpr int NumLowBitsAvailable = 3;
104};
105
106template<> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
108 return V.getOpaqueValue();
109 }
112 }
113 static constexpr int NumLowBitsAvailable =
115};
116}
117
118namespace clang {
119/// APValue - This class implements a discriminated union of [uninitialized]
120/// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset],
121/// [Vector: N * APValue], [Array: N * APValue]
122class APValue {
123 typedef llvm::APFixedPoint APFixedPoint;
124 typedef llvm::APSInt APSInt;
125 typedef llvm::APFloat APFloat;
126public:
128 /// There is no such object (it's outside its lifetime).
130 /// This object has an indeterminate value (C++ [basic.indet]).
144 };
145
147 typedef llvm::PointerUnion<const ValueDecl *, const Expr *, TypeInfoLValue,
149 PtrTy;
150
151 public:
153 LValueBase(const ValueDecl *P, unsigned I = 0, unsigned V = 0);
154 LValueBase(const Expr *P, unsigned I = 0, unsigned V = 0);
157
158 void Profile(llvm::FoldingSetNodeID &ID) const;
159
160 template <class T>
161 bool is() const { return Ptr.is<T>(); }
162
163 template <class T>
164 T get() const { return Ptr.get<T>(); }
165
166 template <class T>
167 T dyn_cast() const { return Ptr.dyn_cast<T>(); }
168
169 void *getOpaqueValue() const;
170
171 bool isNull() const;
172
173 explicit operator bool() const;
174
175 unsigned getCallIndex() const;
176 unsigned getVersion() const;
179
180 QualType getType() const;
181
182 friend bool operator==(const LValueBase &LHS, const LValueBase &RHS);
183 friend bool operator!=(const LValueBase &LHS, const LValueBase &RHS) {
184 return !(LHS == RHS);
185 }
186 friend llvm::hash_code hash_value(const LValueBase &Base);
187 friend struct llvm::DenseMapInfo<LValueBase>;
188
189 private:
190 PtrTy Ptr;
191 struct LocalState {
192 unsigned CallIndex, Version;
193 };
194 union {
195 LocalState Local;
196 /// The type std::type_info, if this is a TypeInfoLValue.
198 /// The QualType, if this is a DynamicAllocLValue.
200 };
201 };
202
203 /// A FieldDecl or CXXRecordDecl, along with a flag indicating whether we
204 /// mean a virtual or non-virtual base class subobject.
205 typedef llvm::PointerIntPair<const Decl *, 1, bool> BaseOrMemberType;
206
207 /// A non-discriminated union of a base, field, or array index.
209 static_assert(sizeof(uintptr_t) <= sizeof(uint64_t),
210 "pointer doesn't fit in 64 bits?");
211 uint64_t Value;
212
213 public:
215 LValuePathEntry(BaseOrMemberType BaseOrMember);
216 static LValuePathEntry ArrayIndex(uint64_t Index) {
218 Result.Value = Index;
219 return Result;
220 }
221
223 return BaseOrMemberType::getFromOpaqueValue(
224 reinterpret_cast<void *>(Value));
225 }
226 uint64_t getAsArrayIndex() const { return Value; }
227
228 void Profile(llvm::FoldingSetNodeID &ID) const;
229
231 return A.Value == B.Value;
232 }
234 return A.Value != B.Value;
235 }
236 friend llvm::hash_code hash_value(LValuePathEntry A) {
237 return llvm::hash_value(A.Value);
238 }
239 };
241 const void *Ty;
242
243 public:
245
248 };
249 struct NoLValuePath {};
250 struct UninitArray {};
251 struct UninitStruct {};
252
253 template <typename Impl> friend class clang::serialization::BasicReaderBase;
254 friend class ASTImporter;
255 friend class ASTNodeImporter;
256
257private:
258 ValueKind Kind;
259
260 struct ComplexAPSInt {
261 APSInt Real, Imag;
262 ComplexAPSInt() : Real(1), Imag(1) {}
263 };
264 struct ComplexAPFloat {
265 APFloat Real, Imag;
266 ComplexAPFloat() : Real(0.0), Imag(0.0) {}
267 };
268 struct LV;
269 struct Vec {
270 APValue *Elts = nullptr;
271 unsigned NumElts = 0;
272 Vec() = default;
273 Vec(const Vec &) = delete;
274 Vec &operator=(const Vec &) = delete;
275 ~Vec() { delete[] Elts; }
276 };
277 struct Arr {
278 APValue *Elts;
279 unsigned NumElts, ArrSize;
280 Arr(unsigned NumElts, unsigned ArrSize);
281 Arr(const Arr &) = delete;
282 Arr &operator=(const Arr &) = delete;
283 ~Arr();
284 };
285 struct StructData {
286 APValue *Elts;
287 unsigned NumBases;
288 unsigned NumFields;
289 StructData(unsigned NumBases, unsigned NumFields);
290 StructData(const StructData &) = delete;
291 StructData &operator=(const StructData &) = delete;
292 ~StructData();
293 };
294 struct UnionData {
295 const FieldDecl *Field;
296 APValue *Value;
297 UnionData();
298 UnionData(const UnionData &) = delete;
299 UnionData &operator=(const UnionData &) = delete;
300 ~UnionData();
301 };
302 struct AddrLabelDiffData {
303 const AddrLabelExpr* LHSExpr;
304 const AddrLabelExpr* RHSExpr;
305 };
306 struct MemberPointerData;
307
308 // We ensure elsewhere that Data is big enough for LV and MemberPointerData.
309 typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt,
310 ComplexAPFloat, Vec, Arr, StructData,
311 UnionData, AddrLabelDiffData> DataType;
312 static const size_t DataSize = sizeof(DataType);
313
314 DataType Data;
315
316public:
317 APValue() : Kind(None) {}
318 explicit APValue(APSInt I) : Kind(None) {
319 MakeInt(); setInt(std::move(I));
320 }
321 explicit APValue(APFloat F) : Kind(None) {
322 MakeFloat(); setFloat(std::move(F));
323 }
324 explicit APValue(APFixedPoint FX) : Kind(None) {
325 MakeFixedPoint(std::move(FX));
326 }
327 explicit APValue(const APValue *E, unsigned N) : Kind(None) {
328 MakeVector(); setVector(E, N);
329 }
330 APValue(APSInt R, APSInt I) : Kind(None) {
331 MakeComplexInt(); setComplexInt(std::move(R), std::move(I));
332 }
333 APValue(APFloat R, APFloat I) : Kind(None) {
334 MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I));
335 }
336 APValue(const APValue &RHS);
337 APValue(APValue &&RHS);
339 bool IsNullPtr = false)
340 : Kind(None) {
341 MakeLValue(); setLValue(B, O, N, IsNullPtr);
342 }
344 bool OnePastTheEnd, bool IsNullPtr = false)
345 : Kind(None) {
346 MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, IsNullPtr);
347 }
348 APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(None) {
349 MakeArray(InitElts, Size);
350 }
351 APValue(UninitStruct, unsigned B, unsigned M) : Kind(None) {
352 MakeStruct(B, M);
353 }
354 explicit APValue(const FieldDecl *D, const APValue &V = APValue())
355 : Kind(None) {
356 MakeUnion(); setUnion(D, V);
357 }
358 APValue(const ValueDecl *Member, bool IsDerivedMember,
360 MakeMemberPointer(Member, IsDerivedMember, Path);
361 }
362 APValue(const AddrLabelExpr* LHSExpr, const AddrLabelExpr* RHSExpr)
363 : Kind(None) {
364 MakeAddrLabelDiff(); setAddrLabelDiff(LHSExpr, RHSExpr);
365 }
368 Result.Kind = Indeterminate;
369 return Result;
370 }
371
372 APValue &operator=(const APValue &RHS);
373 APValue &operator=(APValue &&RHS);
374
376 if (Kind != None && Kind != Indeterminate)
377 DestroyDataAndMakeUninit();
378 }
379
380 /// Returns whether the object performed allocations.
381 ///
382 /// If APValues are constructed via placement new, \c needsCleanup()
383 /// indicates whether the destructor must be called in order to correctly
384 /// free all allocated memory.
385 bool needsCleanup() const;
386
387 /// Swaps the contents of this and the given APValue.
388 void swap(APValue &RHS);
389
390 /// profile this value. There is no guarantee that values of different
391 /// types will not produce the same profiled value, so the type should
392 /// typically also be profiled if it's not implied by the context.
393 void Profile(llvm::FoldingSetNodeID &ID) const;
394
395 ValueKind getKind() const { return Kind; }
396
397 bool isAbsent() const { return Kind == None; }
398 bool isIndeterminate() const { return Kind == Indeterminate; }
399 bool hasValue() const { return Kind != None && Kind != Indeterminate; }
400
401 bool isInt() const { return Kind == Int; }
402 bool isFloat() const { return Kind == Float; }
403 bool isFixedPoint() const { return Kind == FixedPoint; }
404 bool isComplexInt() const { return Kind == ComplexInt; }
405 bool isComplexFloat() const { return Kind == ComplexFloat; }
406 bool isLValue() const { return Kind == LValue; }
407 bool isVector() const { return Kind == Vector; }
408 bool isArray() const { return Kind == Array; }
409 bool isStruct() const { return Kind == Struct; }
410 bool isUnion() const { return Kind == Union; }
411 bool isMemberPointer() const { return Kind == MemberPointer; }
412 bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; }
413
414 void dump() const;
415 void dump(raw_ostream &OS, const ASTContext &Context) const;
416
417 void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const;
418 void printPretty(raw_ostream &OS, const PrintingPolicy &Policy, QualType Ty,
419 const ASTContext *Ctx = nullptr) const;
420
421 std::string getAsString(const ASTContext &Ctx, QualType Ty) const;
422
423 APSInt &getInt() {
424 assert(isInt() && "Invalid accessor");
425 return *(APSInt *)(char *)&Data;
426 }
427 const APSInt &getInt() const {
428 return const_cast<APValue*>(this)->getInt();
429 }
430
431 /// Try to convert this value to an integral constant. This works if it's an
432 /// integer, null pointer, or offset from a null pointer. Returns true on
433 /// success.
435 const ASTContext &Ctx) const;
436
437 APFloat &getFloat() {
438 assert(isFloat() && "Invalid accessor");
439 return *(APFloat *)(char *)&Data;
440 }
441 const APFloat &getFloat() const {
442 return const_cast<APValue*>(this)->getFloat();
443 }
444
445 APFixedPoint &getFixedPoint() {
446 assert(isFixedPoint() && "Invalid accessor");
447 return *(APFixedPoint *)(char *)&Data;
448 }
449 const APFixedPoint &getFixedPoint() const {
450 return const_cast<APValue *>(this)->getFixedPoint();
451 }
452
454 assert(isComplexInt() && "Invalid accessor");
455 return ((ComplexAPSInt *)(char *)&Data)->Real;
456 }
457 const APSInt &getComplexIntReal() const {
458 return const_cast<APValue*>(this)->getComplexIntReal();
459 }
460
462 assert(isComplexInt() && "Invalid accessor");
463 return ((ComplexAPSInt *)(char *)&Data)->Imag;
464 }
465 const APSInt &getComplexIntImag() const {
466 return const_cast<APValue*>(this)->getComplexIntImag();
467 }
468
470 assert(isComplexFloat() && "Invalid accessor");
471 return ((ComplexAPFloat *)(char *)&Data)->Real;
472 }
473 const APFloat &getComplexFloatReal() const {
474 return const_cast<APValue*>(this)->getComplexFloatReal();
475 }
476
478 assert(isComplexFloat() && "Invalid accessor");
479 return ((ComplexAPFloat *)(char *)&Data)->Imag;
480 }
481 const APFloat &getComplexFloatImag() const {
482 return const_cast<APValue*>(this)->getComplexFloatImag();
483 }
484
485 const LValueBase getLValueBase() const;
487 const CharUnits &getLValueOffset() const {
488 return const_cast<APValue*>(this)->getLValueOffset();
489 }
490 bool isLValueOnePastTheEnd() const;
491 bool hasLValuePath() const;
493 unsigned getLValueCallIndex() const;
494 unsigned getLValueVersion() const;
495 bool isNullPointer() const;
496
497 APValue &getVectorElt(unsigned I) {
498 assert(isVector() && "Invalid accessor");
499 assert(I < getVectorLength() && "Index out of range");
500 return ((Vec *)(char *)&Data)->Elts[I];
501 }
502 const APValue &getVectorElt(unsigned I) const {
503 return const_cast<APValue*>(this)->getVectorElt(I);
504 }
505 unsigned getVectorLength() const {
506 assert(isVector() && "Invalid accessor");
507 return ((const Vec *)(const void *)&Data)->NumElts;
508 }
509
511 assert(isArray() && "Invalid accessor");
512 assert(I < getArrayInitializedElts() && "Index out of range");
513 return ((Arr *)(char *)&Data)->Elts[I];
514 }
515 const APValue &getArrayInitializedElt(unsigned I) const {
516 return const_cast<APValue*>(this)->getArrayInitializedElt(I);
517 }
518 bool hasArrayFiller() const {
520 }
522 assert(isArray() && "Invalid accessor");
523 assert(hasArrayFiller() && "No array filler");
524 return ((Arr *)(char *)&Data)->Elts[getArrayInitializedElts()];
525 }
526 const APValue &getArrayFiller() const {
527 return const_cast<APValue*>(this)->getArrayFiller();
528 }
529 unsigned getArrayInitializedElts() const {
530 assert(isArray() && "Invalid accessor");
531 return ((const Arr *)(const void *)&Data)->NumElts;
532 }
533 unsigned getArraySize() const {
534 assert(isArray() && "Invalid accessor");
535 return ((const Arr *)(const void *)&Data)->ArrSize;
536 }
537
538 unsigned getStructNumBases() const {
539 assert(isStruct() && "Invalid accessor");
540 return ((const StructData *)(const char *)&Data)->NumBases;
541 }
542 unsigned getStructNumFields() const {
543 assert(isStruct() && "Invalid accessor");
544 return ((const StructData *)(const char *)&Data)->NumFields;
545 }
546 APValue &getStructBase(unsigned i) {
547 assert(isStruct() && "Invalid accessor");
548 assert(i < getStructNumBases() && "base class index OOB");
549 return ((StructData *)(char *)&Data)->Elts[i];
550 }
551 APValue &getStructField(unsigned i) {
552 assert(isStruct() && "Invalid accessor");
553 assert(i < getStructNumFields() && "field index OOB");
554 return ((StructData *)(char *)&Data)->Elts[getStructNumBases() + i];
555 }
556 const APValue &getStructBase(unsigned i) const {
557 return const_cast<APValue*>(this)->getStructBase(i);
558 }
559 const APValue &getStructField(unsigned i) const {
560 return const_cast<APValue*>(this)->getStructField(i);
561 }
562
563 const FieldDecl *getUnionField() const {
564 assert(isUnion() && "Invalid accessor");
565 return ((const UnionData *)(const char *)&Data)->Field;
566 }
568 assert(isUnion() && "Invalid accessor");
569 return *((UnionData *)(char *)&Data)->Value;
570 }
571 const APValue &getUnionValue() const {
572 return const_cast<APValue*>(this)->getUnionValue();
573 }
574
575 const ValueDecl *getMemberPointerDecl() const;
578
580 assert(isAddrLabelDiff() && "Invalid accessor");
581 return ((const AddrLabelDiffData *)(const char *)&Data)->LHSExpr;
582 }
584 assert(isAddrLabelDiff() && "Invalid accessor");
585 return ((const AddrLabelDiffData *)(const char *)&Data)->RHSExpr;
586 }
587
588 void setInt(APSInt I) {
589 assert(isInt() && "Invalid accessor");
590 *(APSInt *)(char *)&Data = std::move(I);
591 }
592 void setFloat(APFloat F) {
593 assert(isFloat() && "Invalid accessor");
594 *(APFloat *)(char *)&Data = std::move(F);
595 }
596 void setFixedPoint(APFixedPoint FX) {
597 assert(isFixedPoint() && "Invalid accessor");
598 *(APFixedPoint *)(char *)&Data = std::move(FX);
599 }
600 void setVector(const APValue *E, unsigned N) {
601 MutableArrayRef<APValue> InternalElts = setVectorUninit(N);
602 for (unsigned i = 0; i != N; ++i)
603 InternalElts[i] = E[i];
604 }
605 void setComplexInt(APSInt R, APSInt I) {
606 assert(R.getBitWidth() == I.getBitWidth() &&
607 "Invalid complex int (type mismatch).");
608 assert(isComplexInt() && "Invalid accessor");
609 ((ComplexAPSInt *)(char *)&Data)->Real = std::move(R);
610 ((ComplexAPSInt *)(char *)&Data)->Imag = std::move(I);
611 }
612 void setComplexFloat(APFloat R, APFloat I) {
613 assert(&R.getSemantics() == &I.getSemantics() &&
614 "Invalid complex float (type mismatch).");
615 assert(isComplexFloat() && "Invalid accessor");
616 ((ComplexAPFloat *)(char *)&Data)->Real = std::move(R);
617 ((ComplexAPFloat *)(char *)&Data)->Imag = std::move(I);
618 }
619 void setLValue(LValueBase B, const CharUnits &O, NoLValuePath,
620 bool IsNullPtr);
621 void setLValue(LValueBase B, const CharUnits &O,
622 ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
623 bool IsNullPtr);
624 void setUnion(const FieldDecl *Field, const APValue &Value);
625 void setAddrLabelDiff(const AddrLabelExpr* LHSExpr,
626 const AddrLabelExpr* RHSExpr) {
627 ((AddrLabelDiffData *)(char *)&Data)->LHSExpr = LHSExpr;
628 ((AddrLabelDiffData *)(char *)&Data)->RHSExpr = RHSExpr;
629 }
630
631private:
632 void DestroyDataAndMakeUninit();
633 void MakeInt() {
634 assert(isAbsent() && "Bad state change");
635 new ((void *)&Data) APSInt(1);
636 Kind = Int;
637 }
638 void MakeFloat() {
639 assert(isAbsent() && "Bad state change");
640 new ((void *)(char *)&Data) APFloat(0.0);
641 Kind = Float;
642 }
643 void MakeFixedPoint(APFixedPoint &&FX) {
644 assert(isAbsent() && "Bad state change");
645 new ((void *)(char *)&Data) APFixedPoint(std::move(FX));
647 }
648 void MakeVector() {
649 assert(isAbsent() && "Bad state change");
650 new ((void *)(char *)&Data) Vec();
651 Kind = Vector;
652 }
653 void MakeComplexInt() {
654 assert(isAbsent() && "Bad state change");
655 new ((void *)(char *)&Data) ComplexAPSInt();
657 }
658 void MakeComplexFloat() {
659 assert(isAbsent() && "Bad state change");
660 new ((void *)(char *)&Data) ComplexAPFloat();
662 }
663 void MakeLValue();
664 void MakeArray(unsigned InitElts, unsigned Size);
665 void MakeStruct(unsigned B, unsigned M) {
666 assert(isAbsent() && "Bad state change");
667 new ((void *)(char *)&Data) StructData(B, M);
668 Kind = Struct;
669 }
670 void MakeUnion() {
671 assert(isAbsent() && "Bad state change");
672 new ((void *)(char *)&Data) UnionData();
673 Kind = Union;
674 }
675 void MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember,
676 ArrayRef<const CXXRecordDecl*> Path);
677 void MakeAddrLabelDiff() {
678 assert(isAbsent() && "Bad state change");
679 new ((void *)(char *)&Data) AddrLabelDiffData();
681 }
682
683private:
684 /// The following functions are used as part of initialization, during
685 /// deserialization and importing. Reserve the space so that it can be
686 /// filled in by those steps.
687 MutableArrayRef<APValue> setVectorUninit(unsigned N) {
688 assert(isVector() && "Invalid accessor");
689 Vec *V = ((Vec *)(char *)&Data);
690 V->Elts = new APValue[N];
691 V->NumElts = N;
692 return {V->Elts, V->NumElts};
693 }
694 MutableArrayRef<LValuePathEntry>
695 setLValueUninit(LValueBase B, const CharUnits &O, unsigned Size,
696 bool OnePastTheEnd, bool IsNullPtr);
697 MutableArrayRef<const CXXRecordDecl *>
698 setMemberPointerUninit(const ValueDecl *Member, bool IsDerivedMember,
699 unsigned Size);
700};
701
702} // end namespace clang.
703
704namespace llvm {
705template<> struct DenseMapInfo<clang::APValue::LValueBase> {
706 static clang::APValue::LValueBase getEmptyKey();
707 static clang::APValue::LValueBase getTombstoneKey();
708 static unsigned getHashValue(const clang::APValue::LValueBase &Base);
709 static bool isEqual(const clang::APValue::LValueBase &LHS,
710 const clang::APValue::LValueBase &RHS);
711};
712}
713
714#endif
MutableArrayRef< APValue::LValuePathEntry > setLValueUninit(APValue::LValueBase B, const CharUnits &O, unsigned Size, bool OnePastTheEnd, bool IsNullPtr)
#define V(N, I)
Definition: ASTContext.h:3273
StringRef P
static char ID
Definition: Arena.cpp:183
llvm::APSInt APSInt
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
const char * Data
friend llvm::hash_code hash_value(const LValueBase &Base)
Definition: APValue.cpp:202
friend bool operator!=(const LValueBase &LHS, const LValueBase &RHS)
Definition: APValue.h:183
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: APValue.cpp:127
QualType getType() const
Definition: APValue.cpp:63
unsigned getVersion() const
Definition: APValue.cpp:113
QualType getDynamicAllocType() const
Definition: APValue.cpp:122
QualType getTypeInfoType() const
Definition: APValue.cpp:117
friend bool operator==(const LValueBase &LHS, const LValueBase &RHS)
Definition: APValue.cpp:136
void * DynamicAllocType
The QualType, if this is a DynamicAllocLValue.
Definition: APValue.h:199
static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo)
Definition: APValue.cpp:55
static LValueBase getDynamicAlloc(DynamicAllocLValue LV, QualType Type)
Definition: APValue.cpp:47
void * TypeInfoType
The type std::type_info, if this is a TypeInfoLValue.
Definition: APValue.h:197
void * getOpaqueValue() const
Definition: APValue.cpp:175
unsigned getCallIndex() const
Definition: APValue.cpp:108
A non-discriminated union of a base, field, or array index.
Definition: APValue.h:208
BaseOrMemberType getAsBaseOrMember() const
Definition: APValue.h:222
uint64_t getAsArrayIndex() const
Definition: APValue.h:226
friend llvm::hash_code hash_value(LValuePathEntry A)
Definition: APValue.h:236
friend bool operator!=(LValuePathEntry A, LValuePathEntry B)
Definition: APValue.h:233
static LValuePathEntry ArrayIndex(uint64_t Index)
Definition: APValue.h:216
friend bool operator==(LValuePathEntry A, LValuePathEntry B)
Definition: APValue.h:230
void Profile(llvm::FoldingSetNodeID &ID) const
Definition: APValue.cpp:153
ArrayRef< LValuePathEntry > Path
Definition: APValue.h:244
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition: APValue.h:122
const APSInt & getComplexIntReal() const
Definition: APValue.h:457
APValue(LValueBase B, const CharUnits &O, ArrayRef< LValuePathEntry > Path, bool OnePastTheEnd, bool IsNullPtr=false)
Definition: APValue.h:343
APValue(UninitStruct, unsigned B, unsigned M)
Definition: APValue.h:351
bool hasArrayFiller() const
Definition: APValue.h:518
const LValueBase getLValueBase() const
Definition: APValue.cpp:974
APValue(APFloat F)
Definition: APValue.h:321
void setFloat(APFloat F)
Definition: APValue.h:592
APValue & getArrayInitializedElt(unsigned I)
Definition: APValue.h:510
ArrayRef< LValuePathEntry > getLValuePath() const
Definition: APValue.cpp:994
void swap(APValue &RHS)
Swaps the contents of this and the given APValue.
Definition: APValue.cpp:468
APSInt & getInt()
Definition: APValue.h:423
APValue & getStructField(unsigned i)
Definition: APValue.h:551
void setInt(APSInt I)
Definition: APValue.h:588
APValue(APSInt I)
Definition: APValue.h:318
const FieldDecl * getUnionField() const
Definition: APValue.h:563
const APFloat & getFloat() const
Definition: APValue.h:441
bool isVector() const
Definition: APValue.h:407
APSInt & getComplexIntImag()
Definition: APValue.h:461
unsigned getStructNumFields() const
Definition: APValue.h:542
APValue(LValueBase B, const CharUnits &O, NoLValuePath N, bool IsNullPtr=false)
Definition: APValue.h:338
const APValue & getArrayInitializedElt(unsigned I) const
Definition: APValue.h:515
APValue(APFloat R, APFloat I)
Definition: APValue.h:333
bool isAbsent() const
Definition: APValue.h:397
bool isComplexInt() const
Definition: APValue.h:404
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...
Definition: APValue.h:205
ValueKind getKind() const
Definition: APValue.h:395
bool isLValueOnePastTheEnd() const
Definition: APValue.cpp:979
bool isArray() const
Definition: APValue.h:408
APValue(const APValue *E, unsigned N)
Definition: APValue.h:327
void setFixedPoint(APFixedPoint FX)
Definition: APValue.h:596
unsigned getLValueVersion() const
Definition: APValue.cpp:1005
bool isMemberPointerToDerivedMember() const
Definition: APValue.cpp:1064
unsigned getArrayInitializedElts() const
Definition: APValue.h:529
static APValue IndeterminateValue()
Definition: APValue.h:366
bool isFloat() const
Definition: APValue.h:402
void setComplexInt(APSInt R, APSInt I)
Definition: APValue.h:605
const APFixedPoint & getFixedPoint() const
Definition: APValue.h:449
void Profile(llvm::FoldingSetNodeID &ID) const
profile this value.
Definition: APValue.cpp:479
unsigned getStructNumBases() const
Definition: APValue.h:538
APFixedPoint & getFixedPoint()
Definition: APValue.h:445
APValue(const ValueDecl *Member, bool IsDerivedMember, ArrayRef< const CXXRecordDecl * > Path)
Definition: APValue.h:358
bool needsCleanup() const
Returns whether the object performed allocations.
Definition: APValue.cpp:431
const APValue & getStructBase(unsigned i) const
Definition: APValue.h:556
bool hasValue() const
Definition: APValue.h:399
bool hasLValuePath() const
Definition: APValue.cpp:989
const ValueDecl * getMemberPointerDecl() const
Definition: APValue.cpp:1057
APValue & getUnionValue()
Definition: APValue.h:567
const AddrLabelExpr * getAddrLabelDiffRHS() const
Definition: APValue.h:583
CharUnits & getLValueOffset()
Definition: APValue.cpp:984
void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const
Definition: APValue.cpp:693
void setAddrLabelDiff(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
Definition: APValue.h:625
void setComplexFloat(APFloat R, APFloat I)
Definition: APValue.h:612
bool isComplexFloat() const
Definition: APValue.h:405
APValue & getVectorElt(unsigned I)
Definition: APValue.h:497
APValue & getArrayFiller()
Definition: APValue.h:521
const APValue & getArrayFiller() const
Definition: APValue.h:526
const APFloat & getComplexFloatImag() const
Definition: APValue.h:481
unsigned getVectorLength() const
Definition: APValue.h:505
const APValue & getUnionValue() const
Definition: APValue.h:571
const APValue & getVectorElt(unsigned I) const
Definition: APValue.h:502
APValue(UninitArray, unsigned InitElts, unsigned Size)
Definition: APValue.h:348
bool isLValue() const
Definition: APValue.h:406
void setUnion(const FieldDecl *Field, const APValue &Value)
Definition: APValue.cpp:1050
APValue(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
Definition: APValue.h:362
bool isIndeterminate() const
Definition: APValue.h:398
void setLValue(LValueBase B, const CharUnits &O, NoLValuePath, bool IsNullPtr)
Definition: APValue.cpp:1015
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
Definition: APValue.cpp:1071
bool isMemberPointer() const
Definition: APValue.h:411
const APSInt & getInt() const
Definition: APValue.h:427
const APFloat & getComplexFloatReal() const
Definition: APValue.h:473
APValue(const FieldDecl *D, const APValue &V=APValue())
Definition: APValue.h:354
bool isInt() const
Definition: APValue.h:401
unsigned getArraySize() const
Definition: APValue.h:533
APValue(APSInt R, APSInt I)
Definition: APValue.h:330
bool isUnion() const
Definition: APValue.h:410
bool toIntegralConstant(APSInt &Result, QualType SrcTy, const ASTContext &Ctx) const
Try to convert this value to an integral constant.
Definition: APValue.cpp:954
const CharUnits & getLValueOffset() const
Definition: APValue.h:487
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Definition: APValue.cpp:946
bool isFixedPoint() const
Definition: APValue.h:403
APValue & operator=(const APValue &RHS)
Definition: APValue.cpp:386
unsigned getLValueCallIndex() const
Definition: APValue.cpp:1000
void setVector(const APValue *E, unsigned N)
Definition: APValue.h:600
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
Definition: APValue.h:131
@ None
There is no such object (it's outside its lifetime).
Definition: APValue.h:129
const APValue & getStructField(unsigned i) const
Definition: APValue.h:559
const APSInt & getComplexIntImag() const
Definition: APValue.h:465
bool isStruct() const
Definition: APValue.h:409
bool isNullPointer() const
Definition: APValue.cpp:1010
APSInt & getComplexIntReal()
Definition: APValue.h:453
APFloat & getComplexFloatImag()
Definition: APValue.h:477
APFloat & getComplexFloatReal()
Definition: APValue.h:469
APFloat & getFloat()
Definition: APValue.h:437
APValue & getStructBase(unsigned i)
Definition: APValue.h:546
void dump() const
Definition: ASTDumper.cpp:339
APValue(APFixedPoint FX)
Definition: APValue.h:324
const AddrLabelExpr * getAddrLabelDiffLHS() const
Definition: APValue.h:579
bool isAddrLabelDiff() const
Definition: APValue.h:412
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
Definition: ASTImporter.h:62
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4338
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1271
Symbolic representation of a dynamic allocation.
Definition: APValue.h:65
static unsigned getMaxIndex()
Definition: APValue.h:85
static constexpr int NumLowBitsAvailable
Definition: APValue.h:89
DynamicAllocLValue(unsigned Index)
Definition: APValue.h:70
static DynamicAllocLValue getFromOpaqueValue(void *Value)
Definition: APValue.h:79
This represents one expression.
Definition: Expr.h:110
Represents a member of a struct/union/class.
Definition: Decl.h:3058
A (possibly-)qualified type.
Definition: Type.h:738
Symbolic representation of typeid(T) for some type T.
Definition: APValue.h:44
const Type * getType() const
Definition: APValue.h:51
static TypeInfoLValue getFromOpaqueValue(void *Value)
Definition: APValue.h:55
void * getOpaqueValue()
Definition: APValue.h:54
void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) const
Definition: APValue.cpp:30
The base class of the type hierarchy.
Definition: Type.h:1607
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:706
llvm::APFloat APFloat
Definition: Floating.h:23
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
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...
#define bool
Definition: stdbool.h:20
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
static void * getAsVoidPointer(clang::DynamicAllocLValue V)
Definition: APValue.h:107
static clang::DynamicAllocLValue getFromVoidPointer(void *P)
Definition: APValue.h:110
static void * getAsVoidPointer(clang::TypeInfoLValue V)
Definition: APValue.h:95
static clang::TypeInfoLValue getFromVoidPointer(void *P)
Definition: APValue.h:98