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