From e72aba9c0ff5b19128f54b09a36d2f4c2a53b40b Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 22:35:23 +0000 Subject: [PATCH] Debug Info: move DIScope::getContext back from DwarfDebug. This partially reverts r190330. DIScope::getContext now returns DIScopeRef instead of DIScope. We construct a DIScopeRef from DIScope when we are dealing with subprogram, lexical block or name space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190362 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ++++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 2 +- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 23 --------------------- lib/CodeGen/AsmPrinter/DwarfDebug.h | 3 --- lib/IR/DebugInfo.cpp | 23 +++++++++++++++++++++ 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 4ea843c4ce9..e9a78314bcc 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -200,6 +200,9 @@ namespace llvm { public: explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {} + /// Gets the parent scope for this scope node or returns a + /// default constructed scope. + DIScopeRef getContext() const; StringRef getFilename() const; StringRef getDirectory() const; @@ -213,6 +216,7 @@ namespace llvm { class DIScopeRef { template friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + friend DIScopeRef DIScope::getContext() const; /// Val can be either a MDNode or a MDString, in the latter, /// MDString specifies the type identifier. diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 1a527f24fc6..4893c25c098 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -919,7 +919,7 @@ static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) { // Don't generate a hash for anything scoped inside a function. if (Parent.isSubprogram()) return false; - Parent = DD->getScopeContext(Parent); + Parent = DD->resolve(Parent.getContext()); } return true; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 79bb8849e23..7db6df0e19a 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2649,26 +2649,3 @@ void DwarfDebug::emitDebugStrDWO() { DIScope DwarfDebug::resolve(DIScopeRef SRef) const { return SRef.resolve(TypeIdentifierMap); } - -// If the current node has a parent scope then return that, -// else return an empty scope. -DIScope DwarfDebug::getScopeContext(DIScope S) const { - - if (S.isType()) - return resolve(DIType(S).getContext()); - - if (S.isSubprogram()) - return DISubprogram(S).getContext(); - - if (S.isLexicalBlock()) - return DILexicalBlock(S).getContext(); - - if (S.isLexicalBlockFile()) - return DILexicalBlockFile(S).getContext(); - - if (S.isNameSpace()) - return DINameSpace(S).getContext(); - - assert((S.isFile() || S.isCompileUnit()) && "Unhandled type of scope."); - return DIScope(); -} diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index c18fe37ccb5..e026c668135 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -690,9 +690,6 @@ public: /// or another context nested inside a subprogram. bool isSubprogramContext(const MDNode *Context); - /// Gets the parent scope for this scope node or returns a - /// default constructed scope. - DIScope getScopeContext(DIScope S) const; }; } // End of namespace llvm diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index e0b59649a76..51c9e58b2d7 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -785,6 +785,29 @@ Value *DITemplateValueParameter::getValue() const { return getField(DbgNode, 4); } +// If the current node has a parent scope then return that, +// else return an empty scope. +DIScopeRef DIScope::getContext() const { + + if (isType()) + return DIType(DbgNode).getContext(); + + if (isSubprogram()) + return DIScopeRef(DISubprogram(DbgNode).getContext()); + + if (isLexicalBlock()) + return DIScopeRef(DILexicalBlock(DbgNode).getContext()); + + if (isLexicalBlockFile()) + return DIScopeRef(DILexicalBlockFile(DbgNode).getContext()); + + if (isNameSpace()) + return DIScopeRef(DINameSpace(DbgNode).getContext()); + + assert((isFile() || isCompileUnit()) && "Unhandled type of scope."); + return DIScopeRef(NULL); +} + StringRef DIScope::getFilename() const { if (!DbgNode) return StringRef(); -- 2.34.1