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
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-14 02:50:07 +00:00
parent 355ec009e5
commit 32cb99437e
2 changed files with 26 additions and 11 deletions

View File

@ -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.

View File

@ -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) {