Narrow down the type of CallInst::getFunctionType to a FunctionType
[oota-llvm.git] / include / llvm / IR / DebugInfo.h
index 2d84f0f0ad65ae47cef0e38369e112e3ae6415f8..18b0c72b0087da7178a0c1ca32d73927d3519141 100644 (file)
@@ -58,51 +58,15 @@ class DIObjCProperty;
 /// \brief Maps from type identifier to the actual MDNode.
 typedef DenseMap<const MDString *, MDNode *> DITypeIdentifierMap;
 
-/// \brief A thin wraper around MDNode to access encoded debug info.
-///
-/// This should not be stored in a container, because the underlying MDNode may
-/// change in certain situations.
 class DIDescriptor {
-public:
-  /// \brief Duplicated debug info flags.
-  ///
-  /// \see DebugNode::DIFlags.
-  enum {
-#define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = DebugNode::Flag##NAME,
-#include "llvm/IR/DebugInfoFlags.def"
-    FlagAccessibility = DebugNode::FlagAccessibility
-  };
-
-protected:
-  const MDNode *DbgNode;
+  MDNode *N;
 
 public:
-  explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
-  DIDescriptor(const DebugNode *N) : DbgNode(N) {}
-
-  MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
-  operator MDNode *() const { return get(); }
-  MDNode *operator->() const { return get(); }
-  MDNode &operator*() const { return *get(); }
-
-  // An explicit operator bool so that we can do testing of DI values
-  // easily.
-  // FIXME: This operator bool isn't actually protecting anything at the
-  // moment due to the conversion operator above making DIDescriptor nodes
-  // implicitly convertable to bool.
-  explicit operator bool() const { return DbgNode != nullptr; }
-
-  bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; }
-  bool operator!=(DIDescriptor Other) const { return !operator==(Other); }
-
-  uint16_t getTag() const {
-    if (auto *N = dyn_cast_or_null<DebugNode>(get()))
-      return N->getTag();
-    return 0;
-  }
+  DIDescriptor(const MDNode *N = nullptr) : N(const_cast<MDNode *>(N)) {}
 
-  void print(raw_ostream &OS) const;
-  void dump() const;
+  operator MDNode *() const { return N; }
+  MDNode *operator->() const { return N; }
+  MDNode &operator*() const { return *N; }
 };
 
 #define DECLARE_SIMPLIFY_DESCRIPTOR(DESC)                                      \
@@ -136,6 +100,9 @@ DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
 
 typedef DebugNodeArray DIArray;
 typedef MDTypeRefArray DITypeArray;
+typedef DebugNodeRef DIDescriptorRef;
+typedef MDScopeRef DIScopeRef;
+typedef MDTypeRef DITypeRef;
 
 class DISubrange {
   MDSubrange *N;
@@ -160,11 +127,6 @@ public:
   MDEnumerator &operator*() const { return *N; }
 };
 
-template <typename T> class DIRef;
-typedef DIRef<DIDescriptor> DIDescriptorRef;
-typedef DIRef<DIScope> DIScopeRef;
-typedef DIRef<DIType> DITypeRef;
-
 class DIScope {
   MDScope *N;
 
@@ -177,32 +139,6 @@ public:
   MDScope &operator*() const { return *N; }
 };
 
-/// \brief Represents reference to a DIDescriptor.
-///
-/// Abstracts over direct and identifier-based metadata references.
-template <typename T> class DIRef {
-  /// \brief Val can be either a MDNode or a MDString.
-  ///
-  /// In the latter, MDString specifies the type identifier.
-  const Metadata *Val;
-
-public:
-  template <class U>
-  DIRef(const TypedDebugNodeRef<U> &Ref,
-        typename std::enable_if<std::is_convertible<U *, T>::value>::type * =
-            nullptr)
-      : Val(Ref) {}
-
-  T resolve(const DITypeIdentifierMap &Map) const;
-  operator Metadata *() const { return const_cast<Metadata *>(Val); }
-};
-
-template <>
-DIDescriptor DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const;
-template <>
-DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const;
-template <> DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const;
-
 class DIType {
   MDType *N;