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

Devang Patel dpatel at apple.com
Mon Aug 31 14:34:44 PDT 2009


Author: dpatel
Date: Mon Aug 31 16:34:44 2009
New Revision: 80627

URL: http://llvm.org/viewvc/llvm-project?rev=80627&view=rev
Log:
Derive DICompileUnit from 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=80627&r1=80626&r2=80627&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Aug 31 16:34:44 2009
@@ -95,6 +95,7 @@
     bool isSubprogram() const;
     bool isGlobalVariable() const;
     bool isScope() const;
+    bool isCompileUnit() const;
   };
 
   /// DISubrange - This is used to represent ranges, for array bounds.
@@ -129,10 +130,13 @@
   };
 
   /// DICompileUnit - A wrapper for a compile unit.
-  class DICompileUnit : public DIDescriptor {
+  class DICompileUnit : public DIScope {
   public:
-    explicit DICompileUnit(MDNode *N = 0)
-      : DIDescriptor(N, dwarf::DW_TAG_compile_unit) {}
+    explicit DICompileUnit(MDNode *N = 0) {
+      DbgNode = N;
+      if (DbgNode && !isCompileUnit())
+	DbgNode = 0;
+    }
 
     unsigned getLanguage() const     { return getUnsignedField(2); }
     const std::string &getFilename(std::string &F) const {

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

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Aug 31 16:34:44 2009
@@ -227,6 +227,14 @@
   return false;
 }
 
+/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
+bool DIDescriptor::isCompileUnit() const {
+  assert (!isNull() && "Invalid descriptor!");
+  unsigned Tag = getTag();
+
+  return Tag == dwarf::DW_TAG_compile_unit;
+}
+
 //===----------------------------------------------------------------------===//
 // Simple Descriptor Constructors and other Methods
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list