aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2013-09-09 19:23:58 +0000
committerManman Ren <manman.ren@gmail.com>2013-09-09 19:23:58 +0000
commit18eb245a2e5ec41b5da1367d5f7e7619532f7ceb (patch)
tree1115d0d84744f4e8df50462657e47e050609effd
parentdb3a9e64f856e3a233a427da1f3969fd3a65a438 (diff)
downloadexternal_llvm-18eb245a2e5ec41b5da1367d5f7e7619532f7ceb.zip
external_llvm-18eb245a2e5ec41b5da1367d5f7e7619532f7ceb.tar.gz
external_llvm-18eb245a2e5ec41b5da1367d5f7e7619532f7ceb.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190330 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/DebugInfo.h3
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp10
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp23
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.h3
-rw-r--r--lib/IR/DebugInfo.cpp23
5 files changed, 31 insertions, 31 deletions
diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h
index df9c0c7..a758fcc 100644
--- a/include/llvm/DebugInfo.h
+++ b/include/llvm/DebugInfo.h
@@ -200,9 +200,6 @@ 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.
- DIScope getContext() const;
StringRef getFilename() const;
StringRef getDirectory() const;
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 6ec6883..f9ce591 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -913,19 +913,19 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DIDerivedType DTy) {
/// Return true if the type is appropriately scoped to be contained inside
/// its own type unit.
-static bool isTypeUnitScoped(DIType Ty) {
+static bool isTypeUnitScoped(DIType Ty, const DwarfDebug *DD) {
DIScope Parent = Ty.getContext();
while (Parent) {
// Don't generate a hash for anything scoped inside a function.
if (Parent.isSubprogram())
return false;
- Parent = Parent.getContext();
+ Parent = DD->getScopeContext(Parent);
}
return true;
}
/// Return true if the type should be split out into a type unit.
-static bool shouldCreateTypeUnit(DICompositeType CTy) {
+static bool shouldCreateTypeUnit(DICompositeType CTy, const DwarfDebug *DD) {
uint16_t Tag = CTy.getTag();
switch (Tag) {
@@ -936,7 +936,7 @@ static bool shouldCreateTypeUnit(DICompositeType CTy) {
// If this is a class, structure, union, or enumeration type
// that is not a declaration, is a type definition, and not scoped
// inside a function then separate this out as a type unit.
- if (CTy.isForwardDecl() || !isTypeUnitScoped(CTy))
+ if (CTy.isForwardDecl() || !isTypeUnitScoped(CTy, DD))
return 0;
return 1;
default:
@@ -1138,7 +1138,7 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
}
// If this is a type applicable to a type unit it then add it to the
// list of types we'll compute a hash for later.
- if (shouldCreateTypeUnit(CTy))
+ if (shouldCreateTypeUnit(CTy, DD))
DD->addTypeUnitType(&Buffer);
}
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index bdcb813..1cfadc9 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/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();
+}
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h
index f8c27d9..afac39c 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -690,6 +690,9 @@ 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 4546098..dc22db3 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -779,29 +779,6 @@ Value *DITemplateValueParameter::getValue() const {
return getField(DbgNode, 4);
}
-// If the current node has a parent scope then return that,
-// else return an empty scope.
-DIScope DIScope::getContext() const {
-
- if (isType())
- return DIType(DbgNode).getContext();
-
- if (isSubprogram())
- return DISubprogram(DbgNode).getContext();
-
- if (isLexicalBlock())
- return DILexicalBlock(DbgNode).getContext();
-
- if (isLexicalBlockFile())
- return DILexicalBlockFile(DbgNode).getContext();
-
- if (isNameSpace())
- return DINameSpace(DbgNode).getContext();
-
- assert((isFile() || isCompileUnit()) && "Unhandled type of scope.");
- return DIScope();
-}
-
StringRef DIScope::getFilename() const {
if (!DbgNode)
return StringRef();