[llvm-commits] [llvm] r80620 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp

Devang Patel dpatel at apple.com
Mon Aug 31 13:44:45 PDT 2009


Author: dpatel
Date: Mon Aug 31 15:44:45 2009
New Revision: 80620

URL: http://llvm.org/viewvc/llvm-project?rev=80620&view=rev
Log:
Introduce DIScope.

Modified:
    llvm/trunk/include/llvm/Analysis/DebugInfo.h
    llvm/trunk/lib/Analysis/DebugInfo.cpp

Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=80620&r1=80619&r2=80620&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Aug 31 15:44:45 2009
@@ -94,6 +94,7 @@
     bool isVariable() const;
     bool isSubprogram() const;
     bool isGlobalVariable() const;
+    bool isScope() const;
   };
 
   /// DISubrange - This is used to represent ranges, for array bounds.
@@ -118,6 +119,15 @@
     }
   };
 
+  /// DIScope - A base class for various scopes.
+  class DIScope : public DIDescriptor {
+  public:
+    explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
+      if (DbgNode && !isScope())
+        DbgNode = 0;
+    }
+  };
+
   /// DICompileUnit - A wrapper for a compile unit.
   class DICompileUnit : public DIDescriptor {
   public:

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=80620&r1=80619&r2=80620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Aug 31 15:44:45 2009
@@ -210,6 +210,22 @@
   return Tag == dwarf::DW_TAG_variable;
 }
 
+/// isScope - Return true if the specified tag is one of the scope 
+/// related tag.
+bool DIDescriptor::isScope() const {
+  assert (!isNull() && "Invalid descriptor!");
+  unsigned Tag = getTag();
+
+  switch (Tag) {
+    case dwarf::DW_TAG_compile_unit:
+    case dwarf::DW_TAG_lexical_block:
+    case dwarf::DW_TAG_subprogram:
+      return true;
+    default:
+      break;
+  }
+  return false;
+}
 
 //===----------------------------------------------------------------------===//
 // Simple Descriptor Constructors and other Methods





More information about the llvm-commits mailing list