From 32cb99437ef2921bcad7e62de0c3438d594997e6 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 14 Apr 2015 02:50:07 +0000 Subject: [PATCH] DebugInfo: Add MDLexicalBlockBase::getLine(), etc. Add a few functions from `DILexicalBlock` to `MDLexicalBlockBase`, leaving `DILexicalBlock` a simple wrapper. IMO, the new functions (`getLine()` and `getColumn()`) don't really belong in the base class, but to simplify transitioning old code it seems like the right incremental step. I've explicitly deleted them in `MDLexicalBlockFile`, and eventually the callers should be updated to downcast to `MDLexicalBlock` directly and the forwarding functions removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234842 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DebugInfo.h | 14 +++----------- include/llvm/IR/DebugInfoMetadata.h | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index e3a079eebfc..ca3b0d173db 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -497,17 +497,9 @@ public: MDLexicalBlockBase *operator->() const { return get(); } MDLexicalBlockBase &operator*() const { return *get(); } - DIScope getContext() const { return DIScope(get()->getScope()); } - unsigned getLineNumber() const { - if (auto *N = dyn_cast(get())) - return N->getLine(); - return 0; - } - unsigned getColumnNumber() const { - if (auto *N = dyn_cast(get())) - return N->getColumn(); - return 0; - } + DIScope getContext() const { return get()->getScope(); } + unsigned getLineNumber() const { return get()->getLine(); } + unsigned getColumnNumber() const { return get()->getColumn(); } }; /// \brief This is a wrapper for a lexical block with a filename change. diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 97c85559ea1..e16e4319aa9 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -1446,6 +1446,13 @@ public: Metadata *getRawScope() const { return getOperand(1); } + /// \brief Forwarding accessors to LexicalBlock. + /// + /// TODO: Remove these and update code to use \a MDLexicalBlock directly. + /// @{ + inline unsigned getLine() const; + inline unsigned getColumn() const; + /// @} static bool classof(const Metadata *MD) { return MD->getMetadataID() == MDLexicalBlockKind || MD->getMetadataID() == MDLexicalBlockFileKind; @@ -1501,6 +1508,18 @@ public: } }; +unsigned MDLexicalBlockBase::getLine() const { + if (auto *N = dyn_cast(this)) + return N->getLine(); + return 0; +} + +unsigned MDLexicalBlockBase::getColumn() const { + if (auto *N = dyn_cast(this)) + return N->getColumn(); + return 0; +} + class MDLexicalBlockFile : public MDLexicalBlockBase { friend class LLVMContextImpl; friend class MDNode; @@ -1542,6 +1561,10 @@ public: TempMDLexicalBlockFile clone() const { return cloneImpl(); } + // TODO: Remove these once they're gone from MDLexicalBlockBase. + unsigned getLine() const = delete; + unsigned getColumn() const = delete; + unsigned getDiscriminator() const { return Discriminator; } static bool classof(const Metadata *MD) { -- 2.34.1