DebugInfo: Add forwarding getFilename() accessor to new hierarchy
[oota-llvm.git] / include / llvm / IR / DebugInfoMetadata.h
index 4bed55ef1bd6f85a4e0ebe7a6fb51fbd909584c2..374f72776369e451e137e513b1dc0f478e83866a 100644 (file)
@@ -416,6 +416,9 @@ protected:
 public:
   MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
 
+  inline StringRef getFilename() const;
+  inline StringRef getDirectory() const;
+
   /// \brief Return the raw underlying file.
   ///
   /// An \a MDFile is an \a MDScope, but it doesn't point at a separate file
@@ -494,6 +497,18 @@ public:
   }
 };
 
+StringRef MDScope::getFilename() const {
+  if (auto *F = getFile())
+    return F->getFilename();
+  return "";
+}
+
+StringRef MDScope::getDirectory() const {
+  if (auto *F = getFile())
+    return F->getDirectory();
+  return "";
+}
+
 /// \brief Base class for types.
 ///
 /// TODO: Remove the hardcoded name and context, since many types don't use
@@ -1137,6 +1152,10 @@ public:
     return cast_or_null<MDLocation>(getRawInlinedAt());
   }
 
+  MDFile *getFile() const { return getScope()->getFile(); }
+  StringRef getFilename() const { return getScope()->getFilename(); }
+  StringRef getDirectory() const { return getScope()->getDirectory(); }
+
   /// \brief Get the scope where this is inlined.
   ///
   /// Walk through \a getInlinedAt() and return \a getScope() from the deepest
@@ -1628,6 +1647,17 @@ public:
   MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
   MDTypeRef getType() const { return MDTypeRef(getRawType()); }
 
+  StringRef getFilename() const {
+    if (auto *F = getFile())
+      return F->getFilename();
+    return "";
+  }
+  StringRef getDirectory() const {
+    if (auto *F = getFile())
+      return F->getDirectory();
+    return "";
+  }
+
   Metadata *getRawScope() const { return getOperand(0); }
   MDString *getRawName() const { return getOperandAs<MDString>(1); }
   Metadata *getRawFile() const { return getOperand(2); }
@@ -2021,6 +2051,17 @@ public:
   StringRef getSetterName() const { return getStringOperand(3); }
   MDType *getType() const { return cast_or_null<MDType>(getRawType()); }
 
+  StringRef getFilename() const {
+    if (auto *F = getFile())
+      return F->getFilename();
+    return "";
+  }
+  StringRef getDirectory() const {
+    if (auto *F = getFile())
+      return F->getDirectory();
+    return "";
+  }
+
   MDString *getRawName() const { return getOperandAs<MDString>(0); }
   Metadata *getRawFile() const { return getOperand(1); }
   MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }