diff options
author | Devang Patel <dpatel@apple.com> | 2009-09-30 22:34:41 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-09-30 22:34:41 +0000 |
commit | 3733e0ac886bb85bd0735fdee4421683d9be3682 (patch) | |
tree | b42c06c4185598a715c295f8f6126a7410544e08 | |
parent | 1f9b67a27f82ba4d75625c2e260d40cb3b662393 (diff) | |
download | external_llvm-3733e0ac886bb85bd0735fdee4421683d9be3682.zip external_llvm-3733e0ac886bb85bd0735fdee4421683d9be3682.tar.gz external_llvm-3733e0ac886bb85bd0735fdee4421683d9be3682.tar.bz2 |
Add isFOO() helpers. Fix getDirectory() and getFilename() for DIScope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83180 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/DebugInfo.h | 9 | ||||
-rw-r--r-- | lib/Analysis/DebugInfo.cpp | 50 |
2 files changed, 57 insertions, 2 deletions
diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h index c40cfb2..d19cd0b 100644 --- a/include/llvm/Analysis/DebugInfo.h +++ b/include/llvm/Analysis/DebugInfo.h @@ -98,6 +98,10 @@ namespace llvm { bool isScope() const; bool isCompileUnit() const; bool isLexicalBlock() const; + bool isSubrange() const; + bool isEnumerator() const; + bool isType() const; + bool isGlobal() const; }; /// DISubrange - This is used to represent ranges, for array bounds. @@ -131,8 +135,8 @@ namespace llvm { } virtual ~DIScope() {} - virtual const char *getFilename() const { return NULL; } - virtual const char *getDirectory() const { return NULL; } + const char *getFilename() const; + const char *getDirectory() const; }; /// DICompileUnit - A wrapper for a compile unit. @@ -438,6 +442,7 @@ namespace llvm { DbgNode = 0; } DIScope getContext() const { return getFieldAs<DIScope>(1); } + const char *getDirectory() const { return getContext().getDirectory(); } const char *getFilename() const { return getContext().getFilename(); } }; diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index db5a0cb..6df1610 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -189,6 +189,11 @@ bool DIDescriptor::isVariable() const { } } +/// isType - Return true if the specified tag is legal for DIType. +bool DIDescriptor::isType() const { + return isBasicType() || isCompositeType() || isDerivedType(); +} + /// isSubprogram - Return true if the specified tag is legal for /// DISubprogram. bool DIDescriptor::isSubprogram() const { @@ -207,6 +212,11 @@ bool DIDescriptor::isGlobalVariable() const { return Tag == dwarf::DW_TAG_variable; } +/// isGlobal - Return true if the specified tag is legal for DIGlobal. +bool DIDescriptor::isGlobal() const { + return isGlobalVariable(); +} + /// isScope - Return true if the specified tag is one of the scope /// related tag. bool DIDescriptor::isScope() const { @@ -240,6 +250,22 @@ bool DIDescriptor::isLexicalBlock() const { return Tag == dwarf::DW_TAG_lexical_block; } +/// isSubrange - Return true if the specified tag is DW_TAG_subrange_type. +bool DIDescriptor::isSubrange() const { + assert (!isNull() && "Invalid descriptor!"); + unsigned Tag = getTag(); + + return Tag == dwarf::DW_TAG_subrange_type; +} + +/// isEnumerator - Return true if the specified tag is DW_TAG_enumerator. +bool DIDescriptor::isEnumerator() const { + assert (!isNull() && "Invalid descriptor!"); + unsigned Tag = getTag(); + + return Tag == dwarf::DW_TAG_enumerator; +} + //===----------------------------------------------------------------------===// // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// @@ -392,6 +418,30 @@ bool DISubprogram::describes(const Function *F) { return false; } +const char *DIScope::getFilename() const { + if (isLexicalBlock()) + return DILexicalBlock(DbgNode).getFilename(); + else if (isSubprogram()) + return DISubprogram(DbgNode).getFilename(); + else if (isCompileUnit()) + return DICompileUnit(DbgNode).getFilename(); + else + assert (0 && "Invalid DIScope!"); + return NULL; +} + +const char *DIScope::getDirectory() const { + if (isLexicalBlock()) + return DILexicalBlock(DbgNode).getDirectory(); + else if (isSubprogram()) + return DISubprogram(DbgNode).getDirectory(); + else if (isCompileUnit()) + return DICompileUnit(DbgNode).getDirectory(); + else + assert (0 && "Invalid DIScope!"); + return NULL; +} + //===----------------------------------------------------------------------===// // DIDescriptor: dump routines for all descriptors. //===----------------------------------------------------------------------===// |