#include <type_traits>
namespace llvm {
+
class LLVMContext;
class Module;
+class ModuleSlotTracker;
+
template<typename ValueSubClass, typename ItemParentClass>
class SymbolTableListTraits;
public:
enum MetadataKind {
MDTupleKind,
- MDLocationKind,
- GenericDebugNodeKind,
- MDSubrangeKind,
- MDEnumeratorKind,
- MDBasicTypeKind,
- MDDerivedTypeKind,
- MDCompositeTypeKind,
- MDSubroutineTypeKind,
- MDFileKind,
- MDCompileUnitKind,
- MDSubprogramKind,
- MDLexicalBlockKind,
- MDLexicalBlockFileKind,
- MDNamespaceKind,
- MDTemplateTypeParameterKind,
- MDTemplateValueParameterKind,
- MDGlobalVariableKind,
- MDLocalVariableKind,
- MDExpressionKind,
- MDObjCPropertyKind,
- MDImportedEntityKind,
+ DILocationKind,
+ GenericDINodeKind,
+ DISubrangeKind,
+ DIEnumeratorKind,
+ DIBasicTypeKind,
+ DIDerivedTypeKind,
+ DICompositeTypeKind,
+ DISubroutineTypeKind,
+ DIFileKind,
+ DICompileUnitKind,
+ DISubprogramKind,
+ DILexicalBlockKind,
+ DILexicalBlockFileKind,
+ DINamespaceKind,
+ DIModuleKind,
+ DITemplateTypeParameterKind,
+ DITemplateValueParameterKind,
+ DIGlobalVariableKind,
+ DILocalVariableKind,
+ DIExpressionKind,
+ DIObjCPropertyKind,
+ DIImportedEntityKind,
ConstantAsMetadataKind,
LocalAsMetadataKind,
MDStringKind
Metadata(unsigned ID, StorageType Storage)
: SubclassID(ID), Storage(Storage), SubclassData16(0), SubclassData32(0) {
}
- ~Metadata() {}
+ ~Metadata() = default;
/// \brief Default handling of a changed operand, which asserts.
///
///
/// If \c M is provided, metadata nodes will be numbered canonically;
/// otherwise, pointer addresses are substituted.
- void print(raw_ostream &OS, const Module *M = nullptr) const;
+ /// @{
+ void print(raw_ostream &OS, const Module *M = nullptr,
+ bool IsForDebug = false) const;
+ void print(raw_ostream &OS, ModuleSlotTracker &MST, const Module *M = nullptr,
+ bool IsForDebug = false) const;
+ /// @}
/// \brief Print as operand.
///
///
/// If \c M is provided, metadata nodes will be numbered canonically;
/// otherwise, pointer addresses are substituted.
+ /// @{
void printAsOperand(raw_ostream &OS, const Module *M = nullptr) const;
+ void printAsOperand(raw_ostream &OS, ModuleSlotTracker &MST,
+ const Module *M = nullptr) const;
+ /// @}
};
#define HANDLE_METADATA(CLASS) class CLASS;
Metadata *MD;
MetadataAsValue(Type *Ty, Metadata *MD);
- ~MetadataAsValue();
+ ~MetadataAsValue() override;
/// \brief Drop use of metadata (during teardown).
void dropUse() { MD = nullptr; }
: Metadata(ID, Uniqued), ReplaceableMetadataImpl(V->getContext()), V(V) {
assert(V && "Expected valid value");
}
- ~ValueAsMetadata() {}
+ ~ValueAsMetadata() = default;
public:
static ValueAsMetadata *get(Value *V);
template<>
struct DenseMapInfo<AAMDNodes> {
static inline AAMDNodes getEmptyKey() {
- return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(), 0, 0);
+ return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey(),
+ nullptr, nullptr);
}
static inline AAMDNodes getTombstoneKey() {
- return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(), 0, 0);
+ return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey(),
+ nullptr, nullptr);
}
static unsigned getHashValue(const AAMDNodes &Val) {
return DenseMapInfo<MDNode *>::getHashValue(Val.TBAA) ^
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage,
ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None);
- ~MDNode() {}
+ ~MDNode() = default;
void dropAllReferences();
void storeDistinctInContext();
template <class T, class StoreT>
static T *storeImpl(T *N, StorageType Storage, StoreT &Store);
+ template <class T> static T *storeImpl(T *N, StorageType Storage);
private:
void handleChangedOperand(void *Ref, Metadata *New);
public:
MDTupleTypedArrayWrapper() = default;
MDTupleTypedArrayWrapper(const MDTuple *N) : N(N) {}
- operator MDTuple *() const { return const_cast<MDTuple *>(N); }
- MDTuple *operator->() const { return const_cast<MDTuple *>(N); }
- MDTuple &operator*() const { return *const_cast<MDTuple *>(N); }
+
+ template <class U>
+ MDTupleTypedArrayWrapper(
+ const MDTupleTypedArrayWrapper<U> &Other,
+ typename std::enable_if<std::is_convertible<U *, T *>::value>::type * =
+ nullptr)
+ : N(Other.get()) {}
+
+ template <class U>
+ explicit MDTupleTypedArrayWrapper(
+ const MDTupleTypedArrayWrapper<U> &Other,
+ typename std::enable_if<!std::is_convertible<U *, T *>::value>::type * =
+ nullptr)
+ : N(Other.get()) {}
+
+ explicit operator bool() const { return get(); }
+ explicit operator MDTuple *() const { return get(); }
+
+ MDTuple *get() const { return const_cast<MDTuple *>(N); }
+ MDTuple *operator->() const { return get(); }
+ MDTuple &operator*() const { return *get(); }
// FIXME: Fix callers and remove condition on N.
unsigned size() const { return N ? N->getNumOperands() : 0u; }
void addOperand(MDNode *M);
void setOperand(unsigned I, MDNode *New);
StringRef getName() const;
- void print(raw_ostream &ROS) const;
+ void print(raw_ostream &ROS, bool IsForDebug = false) const;
void dump() const;
// ---------------------------------------------------------------------------
} // end llvm namespace
-#endif
+#endif // LLVM_IR_METADATA_H