- /// Ty - Type of data stored in the value.
- ///
- Type Ty;
-
- AlignedCharArrayUnion<DIEInteger, DIEString, DIEExpr, DIELabel, DIEDelta *,
- DIEEntry, DIETypeSignature, DIEBlock *, DIELoc *,
- DIELocList> Val;
- static_assert(sizeof(Val) == sizeof(uint64_t),
- "Only small values should be allocated locally");
-
-public:
- DIEValue() : Ty(isNone) {}
- DIEValue(const DIEValue &X) = default;
- DIEValue &operator=(const DIEValue &X) = default;
-
- explicit operator bool() const { return Ty; }
-
-#define CONSTRUCT_FROM_SMALL(Kind) \
- DIEValue(const DIE##Kind &V) : Ty(is##Kind) { \
- static_assert(std::is_trivially_copyable<DIE##Kind>::value, \
- "Expected trivial type"); \
- new (reinterpret_cast<void *>(Val.buffer)) DIE##Kind(V); \
- }
-#define CONSTRUCT_FROM_LARGE(Kind) \
- DIEValue(const DIE##Kind *V) : Ty(is##Kind) { \
- assert(V && "Expected valid value"); \
- *reinterpret_cast<const DIE##Kind **>(Val.buffer) = V; \
- }
- CONSTRUCT_FROM_SMALL(Integer)
- CONSTRUCT_FROM_SMALL(Expr)
- CONSTRUCT_FROM_SMALL(Label)
- CONSTRUCT_FROM_SMALL(Entry)
- CONSTRUCT_FROM_SMALL(TypeSignature)
- CONSTRUCT_FROM_SMALL(LocList)
- CONSTRUCT_FROM_SMALL(String)
- CONSTRUCT_FROM_LARGE(Delta)
- CONSTRUCT_FROM_LARGE(Block)
- CONSTRUCT_FROM_LARGE(Loc)
-#undef CONSTRUCT_FROM_SMALL
-#undef CONSTRUCT_FROM_LARGE
-
- // Accessors
- Type getType() const { return Ty; }
-
-#define GET_VALUE_REF_SMALL(Kind) \
- const DIE##Kind &getDIE##Kind() const { \
- assert(getType() == is##Kind && "Expected " #Kind); \
- return *reinterpret_cast<const DIE##Kind *>(Val.buffer); \
- }
-#define GET_VALUE_REF_LARGE(Kind) \
- const DIE##Kind &getDIE##Kind() const { \
- assert(getType() == is##Kind && "Expected " #Kind); \
- return **reinterpret_cast<const DIE##Kind *const *>(Val.buffer); \
- }
- GET_VALUE_REF_SMALL(Integer)
- GET_VALUE_REF_SMALL(Expr)
- GET_VALUE_REF_SMALL(Label)
- GET_VALUE_REF_SMALL(Entry)
- GET_VALUE_REF_SMALL(TypeSignature)
- GET_VALUE_REF_SMALL(LocList)
- GET_VALUE_REF_SMALL(String)
- GET_VALUE_REF_LARGE(Delta)
- GET_VALUE_REF_LARGE(Block)
- GET_VALUE_REF_LARGE(Loc)
-#undef GET_VALUE_REF_SMALL
-#undef GET_VALUE_REF_LARGE
-
- /// EmitValue - Emit value via the Dwarf writer.
- ///
- void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
-
- /// SizeOf - Return the size of a value in bytes.
- ///
- unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;