[llvm] r234842 - DebugInfo: Add MDLexicalBlockBase::getLine(), etc.
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Apr 13 19:50:07 PDT 2015
Author: dexonsmith
Date: Mon Apr 13 21:50:07 2015
New Revision: 234842
URL: http://llvm.org/viewvc/llvm-project?rev=234842&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/IR/DebugInfo.h
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234842&r1=234841&r2=234842&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 21:50:07 2015
@@ -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.
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234842&r1=234841&r2=234842&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr 13 21:50:07 2015
@@ -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) {
More information about the llvm-commits
mailing list