From 8ca57e685e7452487232c6e12c2e9a76ee3f4638 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Mon, 13 Apr 2015 19:07:27 +0000 Subject: [PATCH] DebugInfo: Migrate DISubprogram::describes() to new hierarchy, NFC 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 | 2 +- include/llvm/IR/DebugInfoMetadata.h | 5 +++++ lib/IR/DebugInfo.cpp | 12 ------------ lib/IR/DebugInfoMetadata.cpp | 10 ++++++++++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index 32cea6f3487..f4f6bd3ecde 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -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(); } diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 33214589e03..3d2ae12f9be 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -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; } diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 7797a026211..d7f5f6396aa 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -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(getConstant()); } diff --git a/lib/IR/DebugInfoMetadata.cpp b/lib/IR/DebugInfoMetadata.cpp index 72126cc5fb2..ed6206264b0 100644 --- a/lib/IR/DebugInfoMetadata.cpp +++ b/lib/IR/DebugInfoMetadata.cpp @@ -348,6 +348,16 @@ Function *MDSubprogram::getFunction() const { return dyn_cast_or_null(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(nullptr)); -- 2.34.1