clang  9.0.0svn
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/FixedPoint.h"
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/APFloat.h"
19 #include "llvm/ADT/APSInt.h"
20 #include "llvm/ADT/PointerIntPair.h"
21 #include "llvm/ADT/PointerUnion.h"
22 
23 namespace clang {
24  class AddrLabelExpr;
25  class ASTContext;
26  class CharUnits;
27  class CXXRecordDecl;
28  class Decl;
29  class DiagnosticBuilder;
30  class Expr;
31  class FieldDecl;
32  struct PrintingPolicy;
33  class Type;
34  class ValueDecl;
35 
36 /// Symbolic representation of typeid(T) for some type T.
38  const Type *T;
39 
40 public:
41  TypeInfoLValue() : T() {}
42  explicit TypeInfoLValue(const Type *T);
43 
44  const Type *getType() const { return T; }
45  explicit operator bool() const { return T; }
46 
47  void *getOpaqueValue() { return const_cast<Type*>(T); }
50  V.T = reinterpret_cast<const Type*>(Value);
51  return V;
52  }
53 
54  void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) const;
55 };
56 }
57 
58 namespace llvm {
61  return V.getOpaqueValue();
62  }
65  }
66  // Validated by static_assert in APValue.cpp; hardcoded to avoid needing
67  // to include Type.h.
68  static constexpr int NumLowBitsAvailable = 3;
69 };
70 }
71 
72 namespace clang {
73 /// APValue - This class implements a discriminated union of [uninitialized]
74 /// [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset],
75 /// [Vector: N * APValue], [Array: N * APValue]
76 class APValue {
77  typedef llvm::APSInt APSInt;
78  typedef llvm::APFloat APFloat;
79 public:
80  enum ValueKind {
81  /// There is no such object (it's outside its lifetime).
83  /// This object has an indeterminate value (C++ [basic.indet]).
85  Int,
96  AddrLabelDiff
97  };
98 
99  class LValueBase {
100  typedef llvm::PointerUnion<const ValueDecl *, const Expr *, TypeInfoLValue>
101  PtrTy;
102 
103  public:
104  LValueBase() : Local{} {}
105  LValueBase(const ValueDecl *P, unsigned I = 0, unsigned V = 0);
106  LValueBase(const Expr *P, unsigned I = 0, unsigned V = 0);
107  static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo);
108 
109  template <class T>
110  bool is() const { return Ptr.is<T>(); }
111 
112  template <class T>
113  T get() const { return Ptr.get<T>(); }
114 
115  template <class T>
116  T dyn_cast() const { return Ptr.dyn_cast<T>(); }
117 
118  void *getOpaqueValue() const;
119 
120  bool isNull() const;
121 
122  explicit operator bool() const;
123 
124  unsigned getCallIndex() const;
125  unsigned getVersion() const;
126  QualType getTypeInfoType() const;
127 
128  friend bool operator==(const LValueBase &LHS, const LValueBase &RHS);
129  friend bool operator!=(const LValueBase &LHS, const LValueBase &RHS) {
130  return !(LHS == RHS);
131  }
132  friend llvm::hash_code hash_value(const LValueBase &Base);
133 
134  private:
135  PtrTy Ptr;
136  struct LocalState {
137  unsigned CallIndex, Version;
138  };
139  union {
140  LocalState Local;
141  /// The type std::type_info, if this is a TypeInfoLValue.
143  };
144  };
145 
146  /// A FieldDecl or CXXRecordDecl, along with a flag indicating whether we
147  /// mean a virtual or non-virtual base class subobject.
148  typedef llvm::PointerIntPair<const Decl *, 1, bool> BaseOrMemberType;
149 
150  /// A non-discriminated union of a base, field, or array index.
152  static_assert(sizeof(uintptr_t) <= sizeof(uint64_t),
153  "pointer doesn't fit in 64 bits?");
154  uint64_t Value;
155 
156  public:
157  LValuePathEntry() : Value() {}
158  LValuePathEntry(BaseOrMemberType BaseOrMember)
159  : Value{reinterpret_cast<uintptr_t>(BaseOrMember.getOpaqueValue())} {}
160  static LValuePathEntry ArrayIndex(uint64_t Index) {
162  Result.Value = Index;
163  return Result;
164  }
165 
166  BaseOrMemberType getAsBaseOrMember() const {
167  return BaseOrMemberType::getFromOpaqueValue(
168  reinterpret_cast<void *>(Value));
169  }
170  uint64_t getAsArrayIndex() const { return Value; }
171 
173  return A.Value == B.Value;
174  }
176  return A.Value != B.Value;
177  }
178  friend llvm::hash_code hash_value(LValuePathEntry A) {
179  return llvm::hash_value(A.Value);
180  }
181  };
182  struct NoLValuePath {};
183  struct UninitArray {};
184  struct UninitStruct {};
185 private:
186  ValueKind Kind;
187 
188  struct ComplexAPSInt {
189  APSInt Real, Imag;
190  ComplexAPSInt() : Real(1), Imag(1) {}
191  };
192  struct ComplexAPFloat {
193  APFloat Real, Imag;
194  ComplexAPFloat() : Real(0.0), Imag(0.0) {}
195  };
196  struct LV;
197  struct Vec {
198  APValue *Elts;
199  unsigned NumElts;
200  Vec() : Elts(nullptr), NumElts(0) {}
201  ~Vec() { delete[] Elts; }
202  };
203  struct Arr {
204  APValue *Elts;
205  unsigned NumElts, ArrSize;
206  Arr(unsigned NumElts, unsigned ArrSize);
207  ~Arr();
208  };
209  struct StructData {
210  APValue *Elts;
211  unsigned NumBases;
212  unsigned NumFields;
213  StructData(unsigned NumBases, unsigned NumFields);
214  ~StructData();
215  };
216  struct UnionData {
217  const FieldDecl *Field;
218  APValue *Value;
219  UnionData();
220  ~UnionData();
221  };
222  struct AddrLabelDiffData {
223  const AddrLabelExpr* LHSExpr;
224  const AddrLabelExpr* RHSExpr;
225  };
226  struct MemberPointerData;
227 
228  // We ensure elsewhere that Data is big enough for LV and MemberPointerData.
229  typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt,
230  ComplexAPFloat, Vec, Arr, StructData,
231  UnionData, AddrLabelDiffData> DataType;
232  static const size_t DataSize = sizeof(DataType);
233 
234  DataType Data;
235 
236 public:
237  APValue() : Kind(None) {}
238  explicit APValue(APSInt I) : Kind(None) {
239  MakeInt(); setInt(std::move(I));
240  }
241  explicit APValue(APFloat F) : Kind(None) {
242  MakeFloat(); setFloat(std::move(F));
243  }
244  explicit APValue(APFixedPoint FX) : Kind(None) {
245  MakeFixedPoint(std::move(FX));
246  }
247  explicit APValue(const APValue *E, unsigned N) : Kind(None) {
248  MakeVector(); setVector(E, N);
249  }
250  APValue(APSInt R, APSInt I) : Kind(None) {
251  MakeComplexInt(); setComplexInt(std::move(R), std::move(I));
252  }
253  APValue(APFloat R, APFloat I) : Kind(None) {
254  MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I));
255  }
256  APValue(const APValue &RHS);
257  APValue(APValue &&RHS) : Kind(None) { swap(RHS); }
259  bool IsNullPtr = false)
260  : Kind(None) {
261  MakeLValue(); setLValue(B, O, N, IsNullPtr);
262  }
264  bool OnePastTheEnd, bool IsNullPtr = false)
265  : Kind(None) {
266  MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, IsNullPtr);
267  }
268  APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(None) {
269  MakeArray(InitElts, Size);
270  }
271  APValue(UninitStruct, unsigned B, unsigned M) : Kind(None) {
272  MakeStruct(B, M);
273  }
274  explicit APValue(const FieldDecl *D, const APValue &V = APValue())
275  : Kind(None) {
276  MakeUnion(); setUnion(D, V);
277  }
278  APValue(const ValueDecl *Member, bool IsDerivedMember,
279  ArrayRef<const CXXRecordDecl*> Path) : Kind(None) {
280  MakeMemberPointer(Member, IsDerivedMember, Path);
281  }
282  APValue(const AddrLabelExpr* LHSExpr, const AddrLabelExpr* RHSExpr)
283  : Kind(None) {
284  MakeAddrLabelDiff(); setAddrLabelDiff(LHSExpr, RHSExpr);
285  }
287  APValue Result;
288  Result.Kind = Indeterminate;
289  return Result;
290  }
291 
293  if (Kind != None && Kind != Indeterminate)
294  DestroyDataAndMakeUninit();
295  }
296 
297  /// Returns whether the object performed allocations.
298  ///
299  /// If APValues are constructed via placement new, \c needsCleanup()
300  /// indicates whether the destructor must be called in order to correctly
301  /// free all allocated memory.
302  bool needsCleanup() const;
303 
304  /// Swaps the contents of this and the given APValue.
305  void swap(APValue &RHS);
306 
307  ValueKind getKind() const { return Kind; }
308 
309  bool isAbsent() const { return Kind == None; }
310  bool isIndeterminate() const { return Kind == Indeterminate; }
311  bool hasValue() const { return Kind != None && Kind != Indeterminate; }
312 
313  bool isInt() const { return Kind == Int; }
314  bool isFloat() const { return Kind == Float; }
315  bool isFixedPoint() const { return Kind == FixedPoint; }
316  bool isComplexInt() const { return Kind == ComplexInt; }
317  bool isComplexFloat() const { return Kind == ComplexFloat; }
318  bool isLValue() const { return Kind == LValue; }
319  bool isVector() const { return Kind == Vector; }
320  bool isArray() const { return Kind == Array; }
321  bool isStruct() const { return Kind == Struct; }
322  bool isUnion() const { return Kind == Union; }
323  bool isMemberPointer() const { return Kind == MemberPointer; }
324  bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; }
325 
326  void dump() const;
327  void dump(raw_ostream &OS) const;
328 
329  void printPretty(raw_ostream &OS, ASTContext &Ctx, QualType Ty) const;
330  std::string getAsString(ASTContext &Ctx, QualType Ty) const;
331 
332  APSInt &getInt() {
333  assert(isInt() && "Invalid accessor");
334  return *(APSInt*)(char*)Data.buffer;
335  }
336  const APSInt &getInt() const {
337  return const_cast<APValue*>(this)->getInt();
338  }
339 
340  /// Try to convert this value to an integral constant. This works if it's an
341  /// integer, null pointer, or offset from a null pointer. Returns true on
342  /// success.
343  bool toIntegralConstant(APSInt &Result, QualType SrcTy,
344  const ASTContext &Ctx) const;
345 
346  APFloat &getFloat() {
347  assert(isFloat() && "Invalid accessor");
348  return *(APFloat*)(char*)Data.buffer;
349  }
350  const APFloat &getFloat() const {
351  return const_cast<APValue*>(this)->getFloat();
352  }
353 
355  assert(isFixedPoint() && "Invalid accessor");
356  return *(APFixedPoint *)(char *)Data.buffer;
357  }
358  const APFixedPoint &getFixedPoint() const {
359  return const_cast<APValue *>(this)->getFixedPoint();
360  }
361 
362  APSInt &getComplexIntReal() {
363  assert(isComplexInt() && "Invalid accessor");
364  return ((ComplexAPSInt*)(char*)Data.buffer)->Real;
365  }
366  const APSInt &getComplexIntReal() const {
367  return const_cast<APValue*>(this)->getComplexIntReal();
368  }
369 
370  APSInt &getComplexIntImag() {
371  assert(isComplexInt() && "Invalid accessor");
372  return ((ComplexAPSInt*)(char*)Data.buffer)->Imag;
373  }
374  const APSInt &getComplexIntImag() const {
375  return const_cast<APValue*>(this)->getComplexIntImag();
376  }
377 
378  APFloat &getComplexFloatReal() {
379  assert(isComplexFloat() && "Invalid accessor");
380  return ((ComplexAPFloat*)(char*)Data.buffer)->Real;
381  }
382  const APFloat &getComplexFloatReal() const {
383  return const_cast<APValue*>(this)->getComplexFloatReal();
384  }
385 
386  APFloat &getComplexFloatImag() {
387  assert(isComplexFloat() && "Invalid accessor");
388  return ((ComplexAPFloat*)(char*)Data.buffer)->Imag;
389  }
390  const APFloat &getComplexFloatImag() const {
391  return const_cast<APValue*>(this)->getComplexFloatImag();
392  }
393 
394  const LValueBase getLValueBase() const;
395  CharUnits &getLValueOffset();
396  const CharUnits &getLValueOffset() const {
397  return const_cast<APValue*>(this)->getLValueOffset();
398  }
399  bool isLValueOnePastTheEnd() const;
400  bool hasLValuePath() const;
401  ArrayRef<LValuePathEntry> getLValuePath() const;
402  unsigned getLValueCallIndex() const;
403  unsigned getLValueVersion() const;
404  bool isNullPointer() const;
405 
406  APValue &getVectorElt(unsigned I) {
407  assert(isVector() && "Invalid accessor");
408  assert(I < getVectorLength() && "Index out of range");
409  return ((Vec*)(char*)Data.buffer)->Elts[I];
410  }
411  const APValue &getVectorElt(unsigned I) const {
412  return const_cast<APValue*>(this)->getVectorElt(I);
413  }
414  unsigned getVectorLength() const {
415  assert(isVector() && "Invalid accessor");
416  return ((const Vec*)(const void *)Data.buffer)->NumElts;
417  }
418 
420  assert(isArray() && "Invalid accessor");
421  assert(I < getArrayInitializedElts() && "Index out of range");
422  return ((Arr*)(char*)Data.buffer)->Elts[I];
423  }
424  const APValue &getArrayInitializedElt(unsigned I) const {
425  return const_cast<APValue*>(this)->getArrayInitializedElt(I);
426  }
427  bool hasArrayFiller() const {
428  return getArrayInitializedElts() != getArraySize();
429  }
431  assert(isArray() && "Invalid accessor");
432  assert(hasArrayFiller() && "No array filler");
433  return ((Arr*)(char*)Data.buffer)->Elts[getArrayInitializedElts()];
434  }
435  const APValue &getArrayFiller() const {
436  return const_cast<APValue*>(this)->getArrayFiller();
437  }
438  unsigned getArrayInitializedElts() const {
439  assert(isArray() && "Invalid accessor");
440  return ((const Arr*)(const void *)Data.buffer)->NumElts;
441  }
442  unsigned getArraySize() const {
443  assert(isArray() && "Invalid accessor");
444  return ((const Arr*)(const void *)Data.buffer)->ArrSize;
445  }
446 
447  unsigned getStructNumBases() const {
448  assert(isStruct() && "Invalid accessor");
449  return ((const StructData*)(const char*)Data.buffer)->NumBases;
450  }
451  unsigned getStructNumFields() const {
452  assert(isStruct() && "Invalid accessor");
453  return ((const StructData*)(const char*)Data.buffer)->NumFields;
454  }
455  APValue &getStructBase(unsigned i) {
456  assert(isStruct() && "Invalid accessor");
457  return ((StructData*)(char*)Data.buffer)->Elts[i];
458  }
459  APValue &getStructField(unsigned i) {
460  assert(isStruct() && "Invalid accessor");
461  return ((StructData*)(char*)Data.buffer)->Elts[getStructNumBases() + i];
462  }
463  const APValue &getStructBase(unsigned i) const {
464  return const_cast<APValue*>(this)->getStructBase(i);
465  }
466  const APValue &getStructField(unsigned i) const {
467  return const_cast<APValue*>(this)->getStructField(i);
468  }
469 
470  const FieldDecl *getUnionField() const {
471  assert(isUnion() && "Invalid accessor");
472  return ((const UnionData*)(const char*)Data.buffer)->Field;
473  }
475  assert(isUnion() && "Invalid accessor");
476  return *((UnionData*)(char*)Data.buffer)->Value;
477  }
478  const APValue &getUnionValue() const {
479  return const_cast<APValue*>(this)->getUnionValue();
480  }
481 
482  const ValueDecl *getMemberPointerDecl() const;
483  bool isMemberPointerToDerivedMember() const;
484  ArrayRef<const CXXRecordDecl*> getMemberPointerPath() const;
485 
487  assert(isAddrLabelDiff() && "Invalid accessor");
488  return ((const AddrLabelDiffData*)(const char*)Data.buffer)->LHSExpr;
489  }
491  assert(isAddrLabelDiff() && "Invalid accessor");
492  return ((const AddrLabelDiffData*)(const char*)Data.buffer)->RHSExpr;
493  }
494 
495  void setInt(APSInt I) {
496  assert(isInt() && "Invalid accessor");
497  *(APSInt *)(char *)Data.buffer = std::move(I);
498  }
499  void setFloat(APFloat F) {
500  assert(isFloat() && "Invalid accessor");
501  *(APFloat *)(char *)Data.buffer = std::move(F);
502  }
504  assert(isFixedPoint() && "Invalid accessor");
505  *(APFixedPoint *)(char *)Data.buffer = std::move(FX);
506  }
507  void setVector(const APValue *E, unsigned N) {
508  assert(isVector() && "Invalid accessor");
509  ((Vec*)(char*)Data.buffer)->Elts = new APValue[N];
510  ((Vec*)(char*)Data.buffer)->NumElts = N;
511  for (unsigned i = 0; i != N; ++i)
512  ((Vec*)(char*)Data.buffer)->Elts[i] = E[i];
513  }
514  void setComplexInt(APSInt R, APSInt I) {
515  assert(R.getBitWidth() == I.getBitWidth() &&
516  "Invalid complex int (type mismatch).");
517  assert(isComplexInt() && "Invalid accessor");
518  ((ComplexAPSInt *)(char *)Data.buffer)->Real = std::move(R);
519  ((ComplexAPSInt *)(char *)Data.buffer)->Imag = std::move(I);
520  }
521  void setComplexFloat(APFloat R, APFloat I) {
522  assert(&R.getSemantics() == &I.getSemantics() &&
523  "Invalid complex float (type mismatch).");
524  assert(isComplexFloat() && "Invalid accessor");
525  ((ComplexAPFloat *)(char *)Data.buffer)->Real = std::move(R);
526  ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I);
527  }
528  void setLValue(LValueBase B, const CharUnits &O, NoLValuePath,
529  bool IsNullPtr);
530  void setLValue(LValueBase B, const CharUnits &O,
531  ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
532  bool IsNullPtr);
533  void setUnion(const FieldDecl *Field, const APValue &Value) {
534  assert(isUnion() && "Invalid accessor");
535  ((UnionData*)(char*)Data.buffer)->Field = Field;
536  *((UnionData*)(char*)Data.buffer)->Value = Value;
537  }
538  void setAddrLabelDiff(const AddrLabelExpr* LHSExpr,
539  const AddrLabelExpr* RHSExpr) {
540  ((AddrLabelDiffData*)(char*)Data.buffer)->LHSExpr = LHSExpr;
541  ((AddrLabelDiffData*)(char*)Data.buffer)->RHSExpr = RHSExpr;
542  }
543 
544  /// Assign by swapping from a copy of the RHS.
546  swap(RHS);
547  return *this;
548  }
549 
550 private:
551  void DestroyDataAndMakeUninit();
552  void MakeInt() {
553  assert(isAbsent() && "Bad state change");
554  new ((void*)Data.buffer) APSInt(1);
555  Kind = Int;
556  }
557  void MakeFloat() {
558  assert(isAbsent() && "Bad state change");
559  new ((void*)(char*)Data.buffer) APFloat(0.0);
560  Kind = Float;
561  }
562  void MakeFixedPoint(APFixedPoint &&FX) {
563  assert(isAbsent() && "Bad state change");
564  new ((void *)(char *)Data.buffer) APFixedPoint(std::move(FX));
565  Kind = FixedPoint;
566  }
567  void MakeVector() {
568  assert(isAbsent() && "Bad state change");
569  new ((void*)(char*)Data.buffer) Vec();
570  Kind = Vector;
571  }
572  void MakeComplexInt() {
573  assert(isAbsent() && "Bad state change");
574  new ((void*)(char*)Data.buffer) ComplexAPSInt();
575  Kind = ComplexInt;
576  }
577  void MakeComplexFloat() {
578  assert(isAbsent() && "Bad state change");
579  new ((void*)(char*)Data.buffer) ComplexAPFloat();
580  Kind = ComplexFloat;
581  }
582  void MakeLValue();
583  void MakeArray(unsigned InitElts, unsigned Size);
584  void MakeStruct(unsigned B, unsigned M) {
585  assert(isAbsent() && "Bad state change");
586  new ((void*)(char*)Data.buffer) StructData(B, M);
587  Kind = Struct;
588  }
589  void MakeUnion() {
590  assert(isAbsent() && "Bad state change");
591  new ((void*)(char*)Data.buffer) UnionData();
592  Kind = Union;
593  }
594  void MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember,
596  void MakeAddrLabelDiff() {
597  assert(isAbsent() && "Bad state change");
598  new ((void*)(char*)Data.buffer) AddrLabelDiffData();
599  Kind = AddrLabelDiff;
600  }
601 };
602 
603 } // end namespace clang.
604 
605 namespace llvm {
606 template<> struct DenseMapInfo<clang::APValue::LValueBase> {
607  static clang::APValue::LValueBase getEmptyKey();
608  static clang::APValue::LValueBase getTombstoneKey();
609  static unsigned getHashValue(const clang::APValue::LValueBase &Base);
610  static bool isEqual(const clang::APValue::LValueBase &LHS,
611  const clang::APValue::LValueBase &RHS);
612 };
613 }
614 
615 #endif
unsigned getStructNumFields() const
Definition: APValue.h:451
static LValuePathEntry ArrayIndex(uint64_t Index)
Definition: APValue.h:160
const APFixedPoint & getFixedPoint() const
Definition: APValue.h:358
A (possibly-)qualified type.
Definition: Type.h:639
bool operator==(CanQual< T > x, CanQual< U > y)
APValue(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
Definition: APValue.h:282
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:29
static void * getAsVoidPointer(clang::TypeInfoLValue V)
Definition: APValue.h:60
StringRef P
APValue(UninitStruct, unsigned B, unsigned M)
Definition: APValue.h:271
The base class of the type hierarchy.
Definition: Type.h:1414
bool isVector() const
Definition: APValue.h:319
bool hasValue() const
Definition: APValue.h:311
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:172
const APValue & getStructField(unsigned i) const
Definition: APValue.h:466
bool isIndeterminate() const
Definition: APValue.h:310
const AddrLabelExpr * getAddrLabelDiffLHS() const
Definition: APValue.h:486
APFloat & getComplexFloatReal()
Definition: APValue.h:378
static APValue IndeterminateValue()
Definition: APValue.h:286
const APFloat & getComplexFloatReal() const
Definition: APValue.h:382
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:37
bool isAddrLabelDiff() const
Definition: APValue.h:324
const APValue & getArrayFiller() const
Definition: APValue.h:435
const APSInt & getComplexIntReal() const
Definition: APValue.h:366
uint64_t getAsArrayIndex() const
Definition: APValue.h:170
static clang::TypeInfoLValue getFromVoidPointer(void *P)
Definition: APValue.h:63
APValue(APFixedPoint FX)
Definition: APValue.h:244
APValue & operator=(APValue RHS)
Assign by swapping from a copy of the RHS.
Definition: APValue.h:545
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
APValue(const APValue *E, unsigned N)
Definition: APValue.h:247
Represents a member of a struct/union/class.
Definition: Decl.h:2584
const APValue & getUnionValue() const
Definition: APValue.h:478
unsigned getArraySize() const
Definition: APValue.h:442
Symbolic representation of typeid(T) for some type T.
Definition: APValue.h:37
bool isFloat() const
Definition: APValue.h:314
void * TypeInfoType
The type std::type_info, if this is a TypeInfoLValue.
Definition: APValue.h:142
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:37
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool isComplexFloat() const
Definition: APValue.h:317
bool isFixedPoint() const
Definition: APValue.h:315
bool isComplexInt() const
Definition: APValue.h:316
bool isInt() const
Definition: APValue.h:313
APValue(APSInt I)
Definition: APValue.h:238
APSInt & getComplexIntReal()
Definition: APValue.h:362
APValue(UninitArray, unsigned InitElts, unsigned Size)
Definition: APValue.h:268
APValue & getVectorElt(unsigned I)
Definition: APValue.h:406
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
Definition: FixedPoint.h:95
bool isUnion() const
Definition: APValue.h:322
const APFloat & getComplexFloatImag() const
Definition: APValue.h:390
APValue(APFloat F)
Definition: APValue.h:241
APValue & getArrayFiller()
Definition: APValue.h:430
BaseOrMemberType getAsBaseOrMember() const
Definition: APValue.h:166
bool hasArrayFiller() const
Definition: APValue.h:427
const APValue & getVectorElt(unsigned I) const
Definition: APValue.h:411
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
This represents one expression.
Definition: Expr.h:108
const Type * getType() const
Definition: APValue.h:44
llvm::StringRef getAsString(SyncScope S)
Definition: SyncScope.h:50
A non-discriminated union of a base, field, or array index.
Definition: APValue.h:151
const APSInt & getInt() const
Definition: APValue.h:336
#define V(N, I)
Definition: ASTContext.h:2906
llvm::hash_code hash_value(const clang::SanitizerMask &Arg)
Definition: Sanitizers.cpp:51
#define bool
Definition: stdbool.h:15
static bool isVector(QualType QT, QualType ElementType)
This helper function returns true if QT is a vector type that has element type ElementType.
Definition: SemaExpr.cpp:7945
APValue(const FieldDecl *D, const APValue &V=APValue())
Definition: APValue.h:274
APValue(APFloat R, APFloat I)
Definition: APValue.h:253
APValue & getStructField(unsigned i)
Definition: APValue.h:459
APSInt & getComplexIntImag()
Definition: APValue.h:370
const APValue & getArrayInitializedElt(unsigned I) const
Definition: APValue.h:424
The result type of a method or function.
APValue(const ValueDecl *Member, bool IsDerivedMember, ArrayRef< const CXXRecordDecl *> Path)
Definition: APValue.h:278
__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.h:89
const FieldDecl * getUnionField() const
Definition: APValue.h:470
friend llvm::hash_code hash_value(LValuePathEntry A)
Definition: APValue.h:178
void setVector(const APValue *E, unsigned N)
Definition: APValue.h:507
APValue & getStructBase(unsigned i)
Definition: APValue.h:455
unsigned getStructNumBases() const
Definition: APValue.h:447
APValue & getArrayInitializedElt(unsigned I)
Definition: APValue.h:419
This object has an indeterminate value (C++ [basic.indet]).
Definition: APValue.h:84
Kind
const APSInt & getComplexIntImag() const
Definition: APValue.h:374
LValuePathEntry(BaseOrMemberType BaseOrMember)
Definition: APValue.h:158
void setInt(APSInt I)
Definition: APValue.h:495
const AddrLabelExpr * getAddrLabelDiffRHS() const
Definition: APValue.h:490
APValue & getUnionValue()
Definition: APValue.h:474
APFloat & getFloat()
Definition: APValue.h:346
bool isMemberPointer() const
Definition: APValue.h:323
void setAddrLabelDiff(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
Definition: APValue.h:538
bool isLValue() const
Definition: APValue.h:318
Defines the fixed point number interface.
const APValue & getStructBase(unsigned i) const
Definition: APValue.h:463
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3805
Optional< types::ID > Type
Dataflow Directional Tag Classes.
void setFixedPoint(APFixedPoint FX)
Definition: APValue.h:503
bool isAbsent() const
Definition: APValue.h:309
unsigned getArrayInitializedElts() const
Definition: APValue.h:438
APValue(APSInt R, APSInt I)
Definition: APValue.h:250
APValue(LValueBase B, const CharUnits &O, NoLValuePath N, bool IsNullPtr=false)
Definition: APValue.h:258
const APFloat & getFloat() const
Definition: APValue.h:350
bool isArray() const
Definition: APValue.h:320
bool isStruct() const
Definition: APValue.h:321
friend bool operator!=(const LValueBase &LHS, const LValueBase &RHS)
Definition: APValue.h:129
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:76
ValueKind getKind() const
Definition: APValue.h:307
APFloat & getComplexFloatImag()
Definition: APValue.h:386
const CharUnits & getLValueOffset() const
Definition: APValue.h:396
There is no such object (it&#39;s outside its lifetime).
Definition: APValue.h:82
APValue(LValueBase B, const CharUnits &O, ArrayRef< LValuePathEntry > Path, bool OnePastTheEnd, bool IsNullPtr=false)
Definition: APValue.h:263
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:148
void print(llvm::raw_ostream &Out, const PrintingPolicy &Policy) const
Definition: APValue.cpp:28
static TypeInfoLValue getFromOpaqueValue(void *Value)
Definition: APValue.h:48
void * getOpaqueValue()
Definition: APValue.h:47
void setFloat(APFloat F)
Definition: APValue.h:499
void setComplexInt(APSInt R, APSInt I)
Definition: APValue.h:514
void setUnion(const FieldDecl *Field, const APValue &Value)
Definition: APValue.h:533
APSInt & getInt()
Definition: APValue.h:332
APFixedPoint & getFixedPoint()
Definition: APValue.h:354
void setComplexFloat(APFloat R, APFloat I)
Definition: APValue.h:521
friend bool operator!=(LValuePathEntry A, LValuePathEntry B)
Definition: APValue.h:175
APValue(APValue &&RHS)
Definition: APValue.h:257
unsigned getVectorLength() const
Definition: APValue.h:414