llvm/llvm/include/llvm/IR/TrackingMDRef.h

//===- llvm/IR/TrackingMDRef.h - Tracking Metadata references ---*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// References to metadata that track RAUW.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_IR_TRACKINGMDREF_H
#define LLVM_IR_TRACKINGMDREF_H

#include "llvm/IR/Metadata.h"
#include <algorithm>
#include <cassert>

namespace llvm {

/// Tracking metadata reference.
///
/// This class behaves like \a TrackingVH, but for metadata.
class TrackingMDRef {};

/// Typed tracking ref.
///
/// Track refererences of a particular type.  It's useful to use this for \a
/// MDNode and \a ValueAsMetadata.
template <class T> class TypedTrackingMDRef {};

TrackingMDNodeRef;
TrackingValueAsMetadataRef;

// Expose the underlying metadata to casting.
template <> struct simplify_type<TrackingMDRef> {};

template <> struct simplify_type<const TrackingMDRef> {};

simplify_type<TypedTrackingMDRef<T>>;

simplify_type<const TypedTrackingMDRef<T>>;

} // end namespace llvm

#endif // LLVM_IR_TRACKINGMDREF_H