From 77bf295dbb0b049fdec853ced0763084c43b2438 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 8 Mar 2010 22:02:50 +0000 Subject: Derive DIType from DIScope. This simplifies getContext() where for members the context is a type. This also eliminates need of CompileUnitMaps maintained by dwarf writer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97990 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DebugInfo.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/Analysis/DebugInfo.cpp') diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 5e931c6..4ea1ce9 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -243,7 +243,7 @@ bool DIDescriptor::isEnumerator() const { // Simple Descriptor Constructors and other Methods //===----------------------------------------------------------------------===// -DIType::DIType(MDNode *N) : DIDescriptor(N) { +DIType::DIType(MDNode *N) : DIScope(N) { if (!N) return; if (!isBasicType() && !isDerivedType() && !isCompositeType()) { DbgNode = 0; @@ -412,6 +412,8 @@ bool DISubprogram::describes(const Function *F) { } StringRef DIScope::getFilename() const { + if (!DbgNode) + return StringRef(); if (isLexicalBlock()) return DILexicalBlock(DbgNode).getFilename(); if (isSubprogram()) @@ -420,11 +422,15 @@ StringRef DIScope::getFilename() const { return DICompileUnit(DbgNode).getFilename(); if (isNameSpace()) return DINameSpace(DbgNode).getFilename(); + if (isType()) + return DIType(DbgNode).getFilename(); assert(0 && "Invalid DIScope!"); return StringRef(); } StringRef DIScope::getDirectory() const { + if (!DbgNode) + return StringRef(); if (isLexicalBlock()) return DILexicalBlock(DbgNode).getDirectory(); if (isSubprogram()) @@ -433,6 +439,8 @@ StringRef DIScope::getDirectory() const { return DICompileUnit(DbgNode).getDirectory(); if (isNameSpace()) return DINameSpace(DbgNode).getDirectory(); + if (isType()) + return DIType(DbgNode).getDirectory(); assert(0 && "Invalid DIScope!"); return StringRef(); } -- cgit v1.1