From 33796c5e98ede9afc108580d2e02df61ea7dffb2 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 19:23:58 +0000 Subject: Debug Info: move DIScope::getContext to DwarfDebug. DIScope::getContext is a wrapper function that calls the specific getContext method on each subclass. When we switch DIType::getContext to return DIScopeRef instead of DIScope, DIScope::getContext can no longer return a DIScope without a type identifier map. DIScope::getContext is only used by DwarfDebug, so we move it to DwarfDebug to have easy access to the type identifier map. llvm-svn: 190330 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index bdcb813e227..1cfadc91e03 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2650,3 +2650,26 @@ 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 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(); +} -- cgit v1.2.3