Introduce DIScope.
authorDevang Patel <dpatel@apple.com>
Mon, 31 Aug 2009 20:44:45 +0000 (20:44 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 31 Aug 2009 20:44:45 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80620 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 01c1decb83d207a7458a4d23d70a745159e914b5..b8a6ce3cd543eb6446d47faaaeb041274ed7c461 100644 (file)
@@ -94,6 +94,7 @@ namespace llvm {
     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 @@ namespace llvm {
     }
   };
 
+  /// 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:
index a67539c1a07cb5f87fc63906b2468d974dd6e735..e815931e611743840afb440c6f10a5ff45a6efbe 100644 (file)
@@ -210,6 +210,22 @@ bool DIDescriptor::isGlobalVariable() const {
   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