diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-14 02:50:07 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-04-14 02:50:07 +0000 |
| commit | 5f88ba1d5d8c667d6b7d570ee267ea2a86f4a86a (patch) | |
| tree | 7010c16392abe78e064ac1fcc9c9bf411c10cce0 | |
| parent | e75e50c045aa815a268a6d86de620aa484a0f774 (diff) | |
| download | bcm5719-llvm-5f88ba1d5d8c667d6b7d570ee267ea2a86f4a86a.tar.gz bcm5719-llvm-5f88ba1d5d8c667d6b7d570ee267ea2a86f4a86a.zip | |
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.
llvm-svn: 234842
| -rw-r--r-- | llvm/include/llvm/IR/DebugInfo.h | 14 | ||||
| -rw-r--r-- | llvm/include/llvm/IR/DebugInfoMetadata.h | 23 |
2 files changed, 26 insertions, 11 deletions
diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h index e3a079eebfc..ca3b0d173db 100644 --- a/llvm/include/llvm/IR/DebugInfo.h +++ b/llvm/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<MDLexicalBlock>(get())) - return N->getLine(); - return 0; - } - unsigned getColumnNumber() const { - if (auto *N = dyn_cast<MDLexicalBlock>(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/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 97c85559ea1..e16e4319aa9 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/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<MDLexicalBlock>(this)) + return N->getLine(); + return 0; +} + +unsigned MDLexicalBlockBase::getColumn() const { + if (auto *N = dyn_cast<MDLexicalBlock>(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) { |

