[llvm] r234222 - DebugInfo: Loosen DILexicalBlock constructor

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 6 14:16:11 PDT 2015


Author: dexonsmith
Date: Mon Apr  6 16:16:11 2015
New Revision: 234222

URL: http://llvm.org/viewvc/llvm-project?rev=234222&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234222&r1=234221&r2=234222&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr  6 16:16:11 2015
@@ -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<MDLexicalBlockBase>(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<MDLexicalBlockBase>(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<MDNode>(cast<MDLocation>(DbgNode)->getScope()))
-                     .getDiscriminator()
-               : 0;
+    if (auto *F = dyn_cast<MDLexicalBlockFile>(get()->getScope()))
+      return F->getDiscriminator();
+    return 0;
   }
 
   /// \brief Generate a new discriminator value for this location.





More information about the llvm-commits mailing list