From b31cfda0f8a53fa9ddf15ec454fb65c69e977dc7 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 31 Aug 2009 20:44:45 +0000 Subject: [PATCH] Introduce DIScope. llvm-svn: 80620 --- include/llvm/Analysis/DebugInfo.h | 10 ++++++++++ lib/Analysis/DebugInfo.cpp | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h index 01c1decb83d..b8a6ce3cd54 100644 --- a/include/llvm/Analysis/DebugInfo.h +++ b/include/llvm/Analysis/DebugInfo.h @@ -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: diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index a67539c1a07..e815931e611 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -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