| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 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 DiagnosticBuilder; |
| 28 | class Expr; |
| 29 | class FieldDecl; |
| 30 | class Decl; |
| 31 | class ValueDecl; |
| 32 | class CXXRecordDecl; |
| 33 | class QualType; |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | class APValue { |
| 39 | typedef llvm::APSInt APSInt; |
| 40 | typedef llvm::APFloat APFloat; |
| 41 | public: |
| 42 | enum ValueKind { |
| 43 | Uninitialized, |
| 44 | Int, |
| 45 | Float, |
| 46 | FixedPoint, |
| 47 | ComplexInt, |
| 48 | ComplexFloat, |
| 49 | LValue, |
| 50 | Vector, |
| 51 | Array, |
| 52 | Struct, |
| 53 | Union, |
| 54 | MemberPointer, |
| 55 | AddrLabelDiff |
| 56 | }; |
| 57 | |
| 58 | class LValueBase { |
| 59 | public: |
| 60 | typedef llvm::PointerUnion<const ValueDecl *, const Expr *> PtrTy; |
| 61 | |
| 62 | LValueBase() : CallIndex(0), Version(0) {} |
| 63 | |
| 64 | template <class T> |
| 65 | LValueBase(T P, unsigned I = 0, unsigned V = 0) |
| 66 | : Ptr(P), CallIndex(I), Version(V) {} |
| 67 | |
| 68 | template <class T> |
| 69 | bool is() const { return Ptr.is<T>(); } |
| 70 | |
| 71 | template <class T> |
| 72 | T get() const { return Ptr.get<T>(); } |
| 73 | |
| 74 | template <class T> |
| 75 | T dyn_cast() const { return Ptr.dyn_cast<T>(); } |
| 76 | |
| 77 | void *getOpaqueValue() const; |
| 78 | |
| 79 | bool isNull() const; |
| 80 | |
| 81 | explicit operator bool () const; |
| 82 | |
| 83 | PtrTy getPointer() const { |
| 84 | return Ptr; |
| 85 | } |
| 86 | |
| 87 | unsigned getCallIndex() const { |
| 88 | return CallIndex; |
| 89 | } |
| 90 | |
| 91 | void setCallIndex(unsigned Index) { |
| 92 | CallIndex = Index; |
| 93 | } |
| 94 | |
| 95 | unsigned getVersion() const { |
| 96 | return Version; |
| 97 | } |
| 98 | |
| 99 | bool operator==(const LValueBase &Other) const { |
| 100 | return Ptr == Other.Ptr && CallIndex == Other.CallIndex && |
| 101 | Version == Other.Version; |
| 102 | } |
| 103 | |
| 104 | private: |
| 105 | PtrTy Ptr; |
| 106 | unsigned CallIndex, Version; |
| 107 | }; |
| 108 | |
| 109 | typedef llvm::PointerIntPair<const Decl *, 1, bool> BaseOrMemberType; |
| 110 | union LValuePathEntry { |
| 111 | |
| 112 | |
| 113 | void *BaseOrMember; |
| 114 | |
| 115 | uint64_t ArrayIndex; |
| 116 | }; |
| 117 | struct NoLValuePath {}; |
| 118 | struct UninitArray {}; |
| 119 | struct UninitStruct {}; |
| 120 | private: |
| 121 | ValueKind Kind; |
| 122 | |
| 123 | struct ComplexAPSInt { |
| 124 | APSInt Real, Imag; |
| 125 | ComplexAPSInt() : Real(1), Imag(1) {} |
| 126 | }; |
| 127 | struct ComplexAPFloat { |
| 128 | APFloat Real, Imag; |
| 129 | ComplexAPFloat() : Real(0.0), Imag(0.0) {} |
| 130 | }; |
| 131 | struct LV; |
| 132 | struct Vec { |
| 133 | APValue *Elts; |
| 134 | unsigned NumElts; |
| 135 | Vec() : Elts(nullptr), NumElts(0) {} |
| 136 | ~Vec() { delete[] Elts; } |
| 137 | }; |
| 138 | struct Arr { |
| 139 | APValue *Elts; |
| 140 | unsigned NumElts, ArrSize; |
| 141 | Arr(unsigned NumElts, unsigned ArrSize); |
| 142 | ~Arr(); |
| 143 | }; |
| 144 | struct StructData { |
| 145 | APValue *Elts; |
| 146 | unsigned NumBases; |
| 147 | unsigned NumFields; |
| 148 | StructData(unsigned NumBases, unsigned NumFields); |
| 149 | ~StructData(); |
| 150 | }; |
| 151 | struct UnionData { |
| 152 | const FieldDecl *Field; |
| 153 | APValue *Value; |
| 154 | UnionData(); |
| 155 | ~UnionData(); |
| 156 | }; |
| 157 | struct AddrLabelDiffData { |
| 158 | const AddrLabelExpr* LHSExpr; |
| 159 | const AddrLabelExpr* RHSExpr; |
| 160 | }; |
| 161 | struct MemberPointerData; |
| 162 | |
| 163 | |
| 164 | typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt, |
| 165 | ComplexAPFloat, Vec, Arr, StructData, |
| 166 | UnionData, AddrLabelDiffData> DataType; |
| 167 | static const size_t DataSize = sizeof(DataType); |
| 168 | |
| 169 | DataType Data; |
| 170 | |
| 171 | public: |
| 172 | APValue() : Kind(Uninitialized) {} |
| 173 | explicit APValue(APSInt I) : Kind(Uninitialized) { |
| 174 | MakeInt(); setInt(std::move(I)); |
| 175 | } |
| 176 | explicit APValue(APFloat F) : Kind(Uninitialized) { |
| 177 | MakeFloat(); setFloat(std::move(F)); |
| 178 | } |
| 179 | explicit APValue(APFixedPoint FX) : Kind(Uninitialized) { |
| 180 | MakeFixedPoint(std::move(FX)); |
| 181 | } |
| 182 | explicit APValue(const APValue *E, unsigned N) : Kind(Uninitialized) { |
| 183 | MakeVector(); setVector(E, N); |
| 184 | } |
| 185 | APValue(APSInt R, APSInt I) : Kind(Uninitialized) { |
| 186 | MakeComplexInt(); setComplexInt(std::move(R), std::move(I)); |
| 187 | } |
| 188 | APValue(APFloat R, APFloat I) : Kind(Uninitialized) { |
| 189 | MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I)); |
| 190 | } |
| 191 | APValue(const APValue &RHS); |
| 192 | APValue(APValue &&RHS) : Kind(Uninitialized) { swap(RHS); } |
| 193 | APValue(LValueBase B, const CharUnits &O, NoLValuePath N, |
| 194 | bool IsNullPtr = false) |
| 195 | : Kind(Uninitialized) { |
| 196 | MakeLValue(); setLValue(B, O, N, IsNullPtr); |
| 197 | } |
| 198 | APValue(LValueBase B, const CharUnits &O, ArrayRef<LValuePathEntry> Path, |
| 199 | bool OnePastTheEnd, bool IsNullPtr = false) |
| 200 | : Kind(Uninitialized) { |
| 201 | MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, IsNullPtr); |
| 202 | } |
| 203 | APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) { |
| 204 | MakeArray(InitElts, Size); |
| 205 | } |
| 206 | APValue(UninitStruct, unsigned B, unsigned M) : Kind(Uninitialized) { |
| 207 | MakeStruct(B, M); |
| 208 | } |
| 209 | explicit APValue(const FieldDecl *D, const APValue &V = APValue()) |
| 210 | : Kind(Uninitialized) { |
| 211 | MakeUnion(); setUnion(D, V); |
| 212 | } |
| 213 | APValue(const ValueDecl *Member, bool IsDerivedMember, |
| 214 | ArrayRef<const CXXRecordDecl*> Path) : Kind(Uninitialized) { |
| 215 | MakeMemberPointer(Member, IsDerivedMember, Path); |
| 216 | } |
| 217 | APValue(const AddrLabelExpr* LHSExpr, const AddrLabelExpr* RHSExpr) |
| 218 | : Kind(Uninitialized) { |
| 219 | MakeAddrLabelDiff(); setAddrLabelDiff(LHSExpr, RHSExpr); |
| 220 | } |
| 221 | |
| 222 | ~APValue() { |
| 223 | MakeUninit(); |
| 224 | } |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | bool needsCleanup() const; |
| 232 | |
| 233 | |
| 234 | void swap(APValue &RHS); |
| 235 | |
| 236 | ValueKind getKind() const { return Kind; } |
| 237 | bool isUninit() const { return Kind == Uninitialized; } |
| 238 | bool isInt() const { return Kind == Int; } |
| 239 | bool isFloat() const { return Kind == Float; } |
| 240 | bool isFixedPoint() const { return Kind == FixedPoint; } |
| 241 | bool isComplexInt() const { return Kind == ComplexInt; } |
| 242 | bool isComplexFloat() const { return Kind == ComplexFloat; } |
| 243 | bool isLValue() const { return Kind == LValue; } |
| 244 | bool isVector() const { return Kind == Vector; } |
| 245 | bool isArray() const { return Kind == Array; } |
| 246 | bool isStruct() const { return Kind == Struct; } |
| 247 | bool isUnion() const { return Kind == Union; } |
| 248 | bool isMemberPointer() const { return Kind == MemberPointer; } |
| 249 | bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; } |
| 250 | |
| 251 | void dump() const; |
| 252 | void dump(raw_ostream &OS) const; |
| 253 | |
| 254 | void printPretty(raw_ostream &OS, ASTContext &Ctx, QualType Ty) const; |
| 255 | std::string getAsString(ASTContext &Ctx, QualType Ty) const; |
| 256 | |
| 257 | APSInt &getInt() { |
| 258 | (0) . __assert_fail ("isInt() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 258, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isInt() && "Invalid accessor"); |
| 259 | return *(APSInt*)(char*)Data.buffer; |
| 260 | } |
| 261 | const APSInt &getInt() const { |
| 262 | return const_cast<APValue*>(this)->getInt(); |
| 263 | } |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | bool toIntegralConstant(APSInt &Result, QualType SrcTy, |
| 269 | const ASTContext &Ctx) const; |
| 270 | |
| 271 | APFloat &getFloat() { |
| 272 | (0) . __assert_fail ("isFloat() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 272, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isFloat() && "Invalid accessor"); |
| 273 | return *(APFloat*)(char*)Data.buffer; |
| 274 | } |
| 275 | const APFloat &getFloat() const { |
| 276 | return const_cast<APValue*>(this)->getFloat(); |
| 277 | } |
| 278 | |
| 279 | APFixedPoint &getFixedPoint() { |
| 280 | (0) . __assert_fail ("isFixedPoint() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 280, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isFixedPoint() && "Invalid accessor"); |
| 281 | return *(APFixedPoint *)(char *)Data.buffer; |
| 282 | } |
| 283 | const APFixedPoint &getFixedPoint() const { |
| 284 | return const_cast<APValue *>(this)->getFixedPoint(); |
| 285 | } |
| 286 | |
| 287 | APSInt &getComplexIntReal() { |
| 288 | (0) . __assert_fail ("isComplexInt() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 288, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isComplexInt() && "Invalid accessor"); |
| 289 | return ((ComplexAPSInt*)(char*)Data.buffer)->Real; |
| 290 | } |
| 291 | const APSInt &getComplexIntReal() const { |
| 292 | return const_cast<APValue*>(this)->getComplexIntReal(); |
| 293 | } |
| 294 | |
| 295 | APSInt &getComplexIntImag() { |
| 296 | (0) . __assert_fail ("isComplexInt() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 296, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isComplexInt() && "Invalid accessor"); |
| 297 | return ((ComplexAPSInt*)(char*)Data.buffer)->Imag; |
| 298 | } |
| 299 | const APSInt &getComplexIntImag() const { |
| 300 | return const_cast<APValue*>(this)->getComplexIntImag(); |
| 301 | } |
| 302 | |
| 303 | APFloat &getComplexFloatReal() { |
| 304 | (0) . __assert_fail ("isComplexFloat() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 304, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isComplexFloat() && "Invalid accessor"); |
| 305 | return ((ComplexAPFloat*)(char*)Data.buffer)->Real; |
| 306 | } |
| 307 | const APFloat &getComplexFloatReal() const { |
| 308 | return const_cast<APValue*>(this)->getComplexFloatReal(); |
| 309 | } |
| 310 | |
| 311 | APFloat &getComplexFloatImag() { |
| 312 | (0) . __assert_fail ("isComplexFloat() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 312, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isComplexFloat() && "Invalid accessor"); |
| 313 | return ((ComplexAPFloat*)(char*)Data.buffer)->Imag; |
| 314 | } |
| 315 | const APFloat &getComplexFloatImag() const { |
| 316 | return const_cast<APValue*>(this)->getComplexFloatImag(); |
| 317 | } |
| 318 | |
| 319 | const LValueBase getLValueBase() const; |
| 320 | CharUnits &getLValueOffset(); |
| 321 | const CharUnits &getLValueOffset() const { |
| 322 | return const_cast<APValue*>(this)->getLValueOffset(); |
| 323 | } |
| 324 | bool isLValueOnePastTheEnd() const; |
| 325 | bool hasLValuePath() const; |
| 326 | ArrayRef<LValuePathEntry> getLValuePath() const; |
| 327 | unsigned getLValueCallIndex() const; |
| 328 | unsigned getLValueVersion() const; |
| 329 | bool isNullPointer() const; |
| 330 | |
| 331 | APValue &getVectorElt(unsigned I) { |
| 332 | (0) . __assert_fail ("isVector() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 332, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isVector() && "Invalid accessor"); |
| 333 | (0) . __assert_fail ("I < getVectorLength() && \"Index out of range\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 333, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < getVectorLength() && "Index out of range"); |
| 334 | return ((Vec*)(char*)Data.buffer)->Elts[I]; |
| 335 | } |
| 336 | const APValue &getVectorElt(unsigned I) const { |
| 337 | return const_cast<APValue*>(this)->getVectorElt(I); |
| 338 | } |
| 339 | unsigned getVectorLength() const { |
| 340 | (0) . __assert_fail ("isVector() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 340, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isVector() && "Invalid accessor"); |
| 341 | return ((const Vec*)(const void *)Data.buffer)->NumElts; |
| 342 | } |
| 343 | |
| 344 | APValue &getArrayInitializedElt(unsigned I) { |
| 345 | (0) . __assert_fail ("isArray() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 345, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isArray() && "Invalid accessor"); |
| 346 | (0) . __assert_fail ("I < getArrayInitializedElts() && \"Index out of range\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 346, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I < getArrayInitializedElts() && "Index out of range"); |
| 347 | return ((Arr*)(char*)Data.buffer)->Elts[I]; |
| 348 | } |
| 349 | const APValue &getArrayInitializedElt(unsigned I) const { |
| 350 | return const_cast<APValue*>(this)->getArrayInitializedElt(I); |
| 351 | } |
| 352 | bool hasArrayFiller() const { |
| 353 | return getArrayInitializedElts() != getArraySize(); |
| 354 | } |
| 355 | APValue &getArrayFiller() { |
| 356 | (0) . __assert_fail ("isArray() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 356, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isArray() && "Invalid accessor"); |
| 357 | (0) . __assert_fail ("hasArrayFiller() && \"No array filler\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 357, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasArrayFiller() && "No array filler"); |
| 358 | return ((Arr*)(char*)Data.buffer)->Elts[getArrayInitializedElts()]; |
| 359 | } |
| 360 | const APValue &getArrayFiller() const { |
| 361 | return const_cast<APValue*>(this)->getArrayFiller(); |
| 362 | } |
| 363 | unsigned getArrayInitializedElts() const { |
| 364 | (0) . __assert_fail ("isArray() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 364, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isArray() && "Invalid accessor"); |
| 365 | return ((const Arr*)(const void *)Data.buffer)->NumElts; |
| 366 | } |
| 367 | unsigned getArraySize() const { |
| 368 | (0) . __assert_fail ("isArray() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 368, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isArray() && "Invalid accessor"); |
| 369 | return ((const Arr*)(const void *)Data.buffer)->ArrSize; |
| 370 | } |
| 371 | |
| 372 | unsigned getStructNumBases() const { |
| 373 | (0) . __assert_fail ("isStruct() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 373, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isStruct() && "Invalid accessor"); |
| 374 | return ((const StructData*)(const char*)Data.buffer)->NumBases; |
| 375 | } |
| 376 | unsigned getStructNumFields() const { |
| 377 | (0) . __assert_fail ("isStruct() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 377, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isStruct() && "Invalid accessor"); |
| 378 | return ((const StructData*)(const char*)Data.buffer)->NumFields; |
| 379 | } |
| 380 | APValue &getStructBase(unsigned i) { |
| 381 | (0) . __assert_fail ("isStruct() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 381, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isStruct() && "Invalid accessor"); |
| 382 | return ((StructData*)(char*)Data.buffer)->Elts[i]; |
| 383 | } |
| 384 | APValue &getStructField(unsigned i) { |
| 385 | (0) . __assert_fail ("isStruct() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 385, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isStruct() && "Invalid accessor"); |
| 386 | return ((StructData*)(char*)Data.buffer)->Elts[getStructNumBases() + i]; |
| 387 | } |
| 388 | const APValue &getStructBase(unsigned i) const { |
| 389 | return const_cast<APValue*>(this)->getStructBase(i); |
| 390 | } |
| 391 | const APValue &getStructField(unsigned i) const { |
| 392 | return const_cast<APValue*>(this)->getStructField(i); |
| 393 | } |
| 394 | |
| 395 | const FieldDecl *getUnionField() const { |
| 396 | (0) . __assert_fail ("isUnion() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 396, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUnion() && "Invalid accessor"); |
| 397 | return ((const UnionData*)(const char*)Data.buffer)->Field; |
| 398 | } |
| 399 | APValue &getUnionValue() { |
| 400 | (0) . __assert_fail ("isUnion() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 400, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUnion() && "Invalid accessor"); |
| 401 | return *((UnionData*)(char*)Data.buffer)->Value; |
| 402 | } |
| 403 | const APValue &getUnionValue() const { |
| 404 | return const_cast<APValue*>(this)->getUnionValue(); |
| 405 | } |
| 406 | |
| 407 | const ValueDecl *getMemberPointerDecl() const; |
| 408 | bool isMemberPointerToDerivedMember() const; |
| 409 | ArrayRef<const CXXRecordDecl*> getMemberPointerPath() const; |
| 410 | |
| 411 | const AddrLabelExpr* getAddrLabelDiffLHS() const { |
| 412 | (0) . __assert_fail ("isAddrLabelDiff() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 412, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isAddrLabelDiff() && "Invalid accessor"); |
| 413 | return ((const AddrLabelDiffData*)(const char*)Data.buffer)->LHSExpr; |
| 414 | } |
| 415 | const AddrLabelExpr* getAddrLabelDiffRHS() const { |
| 416 | (0) . __assert_fail ("isAddrLabelDiff() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 416, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isAddrLabelDiff() && "Invalid accessor"); |
| 417 | return ((const AddrLabelDiffData*)(const char*)Data.buffer)->RHSExpr; |
| 418 | } |
| 419 | |
| 420 | void setInt(APSInt I) { |
| 421 | (0) . __assert_fail ("isInt() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 421, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isInt() && "Invalid accessor"); |
| 422 | *(APSInt *)(char *)Data.buffer = std::move(I); |
| 423 | } |
| 424 | void setFloat(APFloat F) { |
| 425 | (0) . __assert_fail ("isFloat() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 425, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isFloat() && "Invalid accessor"); |
| 426 | *(APFloat *)(char *)Data.buffer = std::move(F); |
| 427 | } |
| 428 | void setFixedPoint(APFixedPoint FX) { |
| 429 | (0) . __assert_fail ("isFixedPoint() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 429, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isFixedPoint() && "Invalid accessor"); |
| 430 | *(APFixedPoint *)(char *)Data.buffer = std::move(FX); |
| 431 | } |
| 432 | void setVector(const APValue *E, unsigned N) { |
| 433 | (0) . __assert_fail ("isVector() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 433, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isVector() && "Invalid accessor"); |
| 434 | ((Vec*)(char*)Data.buffer)->Elts = new APValue[N]; |
| 435 | ((Vec*)(char*)Data.buffer)->NumElts = N; |
| 436 | for (unsigned i = 0; i != N; ++i) |
| 437 | ((Vec*)(char*)Data.buffer)->Elts[i] = E[i]; |
| 438 | } |
| 439 | void setComplexInt(APSInt R, APSInt I) { |
| 440 | (0) . __assert_fail ("R.getBitWidth() == I.getBitWidth() && \"Invalid complex int (type mismatch).\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 441, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(R.getBitWidth() == I.getBitWidth() && |
| 441 | (0) . __assert_fail ("R.getBitWidth() == I.getBitWidth() && \"Invalid complex int (type mismatch).\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 441, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "Invalid complex int (type mismatch)."); |
| 442 | (0) . __assert_fail ("isComplexInt() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 442, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isComplexInt() && "Invalid accessor"); |
| 443 | ((ComplexAPSInt *)(char *)Data.buffer)->Real = std::move(R); |
| 444 | ((ComplexAPSInt *)(char *)Data.buffer)->Imag = std::move(I); |
| 445 | } |
| 446 | void setComplexFloat(APFloat R, APFloat I) { |
| 447 | (0) . __assert_fail ("&R.getSemantics() == &I.getSemantics() && \"Invalid complex float (type mismatch).\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 448, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(&R.getSemantics() == &I.getSemantics() && |
| 448 | (0) . __assert_fail ("&R.getSemantics() == &I.getSemantics() && \"Invalid complex float (type mismatch).\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 448, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "Invalid complex float (type mismatch)."); |
| 449 | (0) . __assert_fail ("isComplexFloat() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 449, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isComplexFloat() && "Invalid accessor"); |
| 450 | ((ComplexAPFloat *)(char *)Data.buffer)->Real = std::move(R); |
| 451 | ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I); |
| 452 | } |
| 453 | void setLValue(LValueBase B, const CharUnits &O, NoLValuePath, |
| 454 | bool IsNullPtr); |
| 455 | void setLValue(LValueBase B, const CharUnits &O, |
| 456 | ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd, |
| 457 | bool IsNullPtr); |
| 458 | void setUnion(const FieldDecl *Field, const APValue &Value) { |
| 459 | (0) . __assert_fail ("isUnion() && \"Invalid accessor\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 459, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUnion() && "Invalid accessor"); |
| 460 | ((UnionData*)(char*)Data.buffer)->Field = Field; |
| 461 | *((UnionData*)(char*)Data.buffer)->Value = Value; |
| 462 | } |
| 463 | void setAddrLabelDiff(const AddrLabelExpr* LHSExpr, |
| 464 | const AddrLabelExpr* RHSExpr) { |
| 465 | ((AddrLabelDiffData*)(char*)Data.buffer)->LHSExpr = LHSExpr; |
| 466 | ((AddrLabelDiffData*)(char*)Data.buffer)->RHSExpr = RHSExpr; |
| 467 | } |
| 468 | |
| 469 | |
| 470 | APValue &operator=(APValue RHS) { |
| 471 | swap(RHS); |
| 472 | return *this; |
| 473 | } |
| 474 | |
| 475 | private: |
| 476 | void DestroyDataAndMakeUninit(); |
| 477 | void MakeUninit() { |
| 478 | if (Kind != Uninitialized) |
| 479 | DestroyDataAndMakeUninit(); |
| 480 | } |
| 481 | void MakeInt() { |
| 482 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 482, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 483 | new ((void*)Data.buffer) APSInt(1); |
| 484 | Kind = Int; |
| 485 | } |
| 486 | void MakeFloat() { |
| 487 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 487, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 488 | new ((void*)(char*)Data.buffer) APFloat(0.0); |
| 489 | Kind = Float; |
| 490 | } |
| 491 | void MakeFixedPoint(APFixedPoint &&FX) { |
| 492 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 492, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 493 | new ((void *)(char *)Data.buffer) APFixedPoint(std::move(FX)); |
| 494 | Kind = FixedPoint; |
| 495 | } |
| 496 | void MakeVector() { |
| 497 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 497, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 498 | new ((void*)(char*)Data.buffer) Vec(); |
| 499 | Kind = Vector; |
| 500 | } |
| 501 | void MakeComplexInt() { |
| 502 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 502, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 503 | new ((void*)(char*)Data.buffer) ComplexAPSInt(); |
| 504 | Kind = ComplexInt; |
| 505 | } |
| 506 | void MakeComplexFloat() { |
| 507 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 507, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 508 | new ((void*)(char*)Data.buffer) ComplexAPFloat(); |
| 509 | Kind = ComplexFloat; |
| 510 | } |
| 511 | void MakeLValue(); |
| 512 | void MakeArray(unsigned InitElts, unsigned Size); |
| 513 | void MakeStruct(unsigned B, unsigned M) { |
| 514 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 514, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 515 | new ((void*)(char*)Data.buffer) StructData(B, M); |
| 516 | Kind = Struct; |
| 517 | } |
| 518 | void MakeUnion() { |
| 519 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 519, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 520 | new ((void*)(char*)Data.buffer) UnionData(); |
| 521 | Kind = Union; |
| 522 | } |
| 523 | void MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember, |
| 524 | ArrayRef<const CXXRecordDecl*> Path); |
| 525 | void MakeAddrLabelDiff() { |
| 526 | (0) . __assert_fail ("isUninit() && \"Bad state change\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/APValue.h", 526, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isUninit() && "Bad state change"); |
| 527 | new ((void*)(char*)Data.buffer) AddrLabelDiffData(); |
| 528 | Kind = AddrLabelDiff; |
| 529 | } |
| 530 | }; |
| 531 | |
| 532 | } |
| 533 | |
| 534 | namespace llvm { |
| 535 | template<> struct DenseMapInfo<clang::APValue::LValueBase> { |
| 536 | static clang::APValue::LValueBase getEmptyKey(); |
| 537 | static clang::APValue::LValueBase getTombstoneKey(); |
| 538 | static unsigned getHashValue(const clang::APValue::LValueBase &Base); |
| 539 | static bool isEqual(const clang::APValue::LValueBase &LHS, |
| 540 | const clang::APValue::LValueBase &RHS); |
| 541 | }; |
| 542 | } |
| 543 | |
| 544 | #endif |
| 545 | |