DebugInfo: DIRef<> => TypedDebugNodeRef<>
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 16 Apr 2015 02:24:01 +0000 (02:24 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Thu, 16 Apr 2015 02:24:01 +0000 (02:24 +0000)
Delete `DIRef<>`, and replace the remaining uses of it with
`TypedDebugNodeRef<>`.  To minimize code churn, I've added typedefs from
`MDTypeRef` to `DITypeRef` (etc.).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235071 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DebugInfo.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/CodeGen/AsmPrinter/DwarfUnit.h
lib/IR/DebugInfo.cpp

index 3233ea34c60e4805df52334f84b9186db7ec43dd..18b0c72b0087da7178a0c1ca32d73927d3519141 100644 (file)
@@ -100,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;
@@ -124,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;
 
@@ -141,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;
 
index b59c5e3e049b4b8a2d578d8bcff7815d137745be..97c9855fe14eec1aa1ea27760b3689c1b19749dc 100644 (file)
@@ -129,7 +129,7 @@ bool DebugLocDwarfExpression::isFrameRegister(unsigned MachineReg) {
 
 /// resolve - Look in the DwarfDebug map for the MDNode that
 /// corresponds to the reference.
-template <typename T> T DbgVariable::resolve(DIRef<T> Ref) const {
+template <typename T> T *DbgVariable::resolve(TypedDebugNodeRef<T> Ref) const {
   return DD->resolve(Ref);
 }
 
index c718baf47baa1b2371d7aa6784d885b15c231071..809e7bdde10b9def00413d6d89362a03ce743948 100644 (file)
@@ -173,7 +173,7 @@ public:
 private:
   /// resolve - Look in the DwarfDebug map for the MDNode that
   /// corresponds to the reference.
-  template <typename T> T resolve(DIRef<T> Ref) const;
+  template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const;
 };
 
 
@@ -577,9 +577,6 @@ public:
   void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
 
   /// Find the MDNode for the given reference.
-  template <typename T> T resolve(DIRef<T> Ref) const {
-    return Ref.resolve(TypeIdentifierMap);
-  }
   template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
     return Ref.resolve(TypeIdentifierMap);
   }
index a7378738d670200068afe76fcc6c417265b79a70..b354255d70996271bf4cfb5b8c3ed415c15c244a 100644 (file)
@@ -342,9 +342,6 @@ protected:
 
   /// resolve - Look in the DwarfDebug map for the MDNode that
   /// corresponds to the reference.
-  template <typename T> T resolve(DIRef<T> Ref) const {
-    return DD->resolve(Ref);
-  }
   template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
     return DD->resolve(Ref);
   }
index d877325b1f167fb3468a73f19d96c65c7d7c80b8..719c28b547f12764755d1c99b5190e664169fcf2 100644 (file)
@@ -307,20 +307,6 @@ bool DebugInfoFinder::addScope(DIScope Scope) {
   return true;
 }
 
-template <>
-DIDescriptor
-DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const {
-  return DIDescriptor(DebugNodeRef(Val).resolve(Map));
-}
-template <>
-DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const {
-  return MDScopeRef(Val).resolve(Map);
-}
-template <>
-DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const {
-  return MDTypeRef(Val).resolve(Map);
-}
-
 bool llvm::stripDebugInfo(Function &F) {
   bool Changed = false;
   for (BasicBlock &BB : F) {