From: Duncan P. N. Exon Smith Date: Mon, 6 Apr 2015 21:16:11 +0000 (+0000) Subject: DebugInfo: Loosen DILexicalBlock constructor X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2925bd0b3c9e0a156404dc02e59fdfda25784dc4;p=oota-llvm.git DebugInfo: Loosen DILexicalBlock constructor This class wraps `MDLexicalBlockBase`, so allow construction from it! Currently doesn't cause any problems because of the explicit `MNode*` constructor, but I'll be removing that soon enough. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234222 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index 2fa68982ac8..24dd02056ad 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -704,7 +704,7 @@ public: class DILexicalBlock : public DIScope { public: explicit DILexicalBlock(const MDNode *N = nullptr) : DIScope(N) {} - DILexicalBlock(const MDLexicalBlock *N) : DIScope(N) {} + DILexicalBlock(const MDLexicalBlockBase *N) : DIScope(N) {} MDLexicalBlockBase *get() const { return cast_or_null(DIDescriptor::get()); @@ -745,10 +745,12 @@ public: return *get(); } - DIScope getContext() const { return getScope(); } + DIScope getContext() const { return get()->getScope(); } unsigned getLineNumber() const { return getScope().getLineNumber(); } unsigned getColumnNumber() const { return getScope().getColumnNumber(); } - DILexicalBlock getScope() const { return DILexicalBlock(get()->getScope()); } + DILexicalBlock getScope() const { + return dyn_cast(get()->getScope()); + } unsigned getDiscriminator() const { return get()->getDiscriminator(); } }; @@ -1050,11 +1052,9 @@ public: // Since discriminators are associated with lexical blocks, make // sure this location is a lexical block before retrieving its // value. - return getScope().isLexicalBlockFile() - ? DILexicalBlockFile( - cast(cast(DbgNode)->getScope())) - .getDiscriminator() - : 0; + if (auto *F = dyn_cast(get()->getScope())) + return F->getDiscriminator(); + return 0; } /// \brief Generate a new discriminator value for this location.