summaryrefslogtreecommitdiff
path: root/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-07-26 17:02:36 +0000
committerEric Christopher <echristo@gmail.com>2013-07-26 17:02:36 +0000
commit956e5aa3bd32212c6902a585a367dbf58d685340 (patch)
treebf293f294cbfb3f7c7501ce3bfdf98fc27a33aa3 /lib/IR/DebugInfo.cpp
parent65985348c5ece4efecce485029b147c45453c4c8 (diff)
downloadllvm-956e5aa3bd32212c6902a585a367dbf58d685340.tar.gz
llvm-956e5aa3bd32212c6902a585a367dbf58d685340.tar.bz2
llvm-956e5aa3bd32212c6902a585a367dbf58d685340.tar.xz
Add a way to get the context of any particular scope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187212 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/DebugInfo.cpp')
-rw-r--r--lib/IR/DebugInfo.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp
index 750231658f..369895ce56 100644
--- a/lib/IR/DebugInfo.cpp
+++ b/lib/IR/DebugInfo.cpp
@@ -692,6 +692,31 @@ 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();
+
+ if (isFile() || isCompileUnit())
+ return DIScope();
+
+ return DIScope();
+}
+
StringRef DIScope::getFilename() const {
if (!DbgNode)
return StringRef();