DebugInfo: Migrate DISubprogram::describes() to new hierarchy, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 13 Apr 2015 19:07:27 +0000 (19:07 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Mon, 13 Apr 2015 19:07:27 +0000 (19:07 +0000)
I don't really like this function at all -- I think it should be as
simple as `return getFunction() == F` -- but for now this seems like the
best we can do.

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

include/llvm/IR/DebugInfo.h
include/llvm/IR/DebugInfoMetadata.h
lib/IR/DebugInfo.cpp
lib/IR/DebugInfoMetadata.cpp

index 32cea6f34879ffb34938be636a3e4d072d0bfc1a..f4f6bd3ecde561a48135218c8ae4ade5fd9164ef 100644 (file)
@@ -520,7 +520,7 @@ public:
   DITypeRef getContainingType() const { return get()->getContainingType(); }
 
   /// \brief Check if this provides debugging information for the function F.
-  bool describes(const Function *F);
+  bool describes(const Function *F) const { return get()->describes(F); }
 
   Function *getFunction() const { return get()->getFunction(); }
 
index 33214589e03420041a479393a40962d443a51b56..3d2ae12f9be812da21c9d9ce48fa5c3e565a3c2c 100644 (file)
@@ -1386,6 +1386,11 @@ public:
   void replaceFunction(std::nullptr_t) { replaceOperandWith(7, nullptr); }
   /// @}
 
+  /// \brief Check if this subprogram decribes the given function.
+  ///
+  /// FIXME: Should this be looking through bitcasts?
+  bool describes(const Function *F) const;
+
   static bool classof(const Metadata *MD) {
     return MD->getMetadataID() == MDSubprogramKind;
   }
index 7797a026211ab5245554bed8037fb3d40cd53b8c..d7f5f6396aa8e7a708b405b8951037e7eb15a38c 100644 (file)
@@ -49,18 +49,6 @@ bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
   return !SP.describes(CurFn);
 }
 
-bool DISubprogram::describes(const Function *F) {
-  assert(F && "Invalid function");
-  if (F == getFunction())
-    return true;
-  StringRef Name = getLinkageName();
-  if (Name.empty())
-    Name = getName();
-  if (F->getName() == Name)
-    return true;
-  return false;
-}
-
 GlobalVariable *DIGlobalVariable::getGlobal() const {
   return dyn_cast_or_null<GlobalVariable>(getConstant());
 }
index 72126cc5fb2b481fdf0733e7e4fc55ddc4ea03a8..ed6206264b0966a4025165fa0c0f6f3f493cfa11 100644 (file)
@@ -348,6 +348,16 @@ Function *MDSubprogram::getFunction() const {
   return dyn_cast_or_null<Function>(getFunctionConstant());
 }
 
+bool MDSubprogram::describes(const Function *F) const {
+  assert(F && "Invalid function");
+  if (F == getFunction())
+    return true;
+  StringRef Name = getLinkageName();
+  if (Name.empty())
+    Name = getName();
+  return F->getName() == Name;
+}
+
 void MDSubprogram::replaceFunction(Function *F) {
   replaceFunction(F ? ConstantAsMetadata::get(F)
                     : static_cast<ConstantAsMetadata *>(nullptr));