[llvm-commits] Patch proposal: DIDescriptor constructors (patch inline)

Renato Golin renato.golin at arm.com
Wed Jul 28 01:40:03 PDT 2010


Debug info in LLVM is now done by passing small objects, rather than
pointers. To some degree it works, but it's difficult to pass derived
objects into functions that would expect base ones.
For that purpose, I have added a few constructors to DIDescriptor to
enable that functionality without changing the way the debug
infrastructure works, but that doesn't work in the opposite direction.

Patch extracted from yesterday's (Tue, 27 Jul, 2010) trunk, now inline.

Modifyed:
  include/llvm/Analysis/DebugInfo.h
  lib/Analysis/DebugInfo.cpp


Index: include/llvm/Analysis/DebugInfo.h
===================================================================
--- include/llvm/Analysis/DebugInfo.h   (revision 109509)
+++ include/llvm/Analysis/DebugInfo.h   (working copy)
@@ -36,6 +36,12 @@
   class LLVMContext;
   class raw_ostream;

+  class DIFile;
+  class DISubprogram;
+  class DILexicalBlock;
+  class DIVariable;
+  class DIType;
+
   /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
   /// This should not be stored in a container, because underly MDNode may
   /// change in certain situations.
@@ -61,6 +67,11 @@
   public:
     explicit DIDescriptor() : DbgNode(0) {}
     explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
+    explicit DIDescriptor(const DIFile F);
+    explicit DIDescriptor(const DISubprogram F);
+    explicit DIDescriptor(const DILexicalBlock F);
+    explicit DIDescriptor(const DIVariable F);
+    explicit DIDescriptor(const DIType F);

     bool Verify() const { return DbgNode != 0; }

Index: lib/Analysis/DebugInfo.cpp
===================================================================
--- lib/Analysis/DebugInfo.cpp  (revision 109509)
+++ lib/Analysis/DebugInfo.cpp  (working copy)
@@ -32,6 +32,21 @@
 // DIDescriptor
 //===----------------------------------------------------------------------===//

+DIDescriptor::DIDescriptor(const DIFile F) : DbgNode(F.DbgNode) {
+}
+
+DIDescriptor::DIDescriptor(const DISubprogram F) : DbgNode(F.DbgNode) {
+}
+
+DIDescriptor::DIDescriptor(const DILexicalBlock F) : DbgNode(F.DbgNode) {
+}
+
+DIDescriptor::DIDescriptor(const DIVariable F) : DbgNode(F.DbgNode) {
+}
+
+DIDescriptor::DIDescriptor(const DIType F) : DbgNode(F.DbgNode) {
+}
+
 StringRef
 DIDescriptor::getStringField(unsigned Elt) const {
   if (DbgNode == 0)



More information about the llvm-commits mailing list