diff options
| author | Eric Christopher <echristo@gmail.com> | 2013-07-26 17:02:36 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2013-07-26 17:02:36 +0000 |
| commit | feea95c88468cadbbed4ca0526826a7d279f2f7d (patch) | |
| tree | b5a914ad7ec9867c76f238969e60642af62bdeac /llvm/lib/IR | |
| parent | b37fba7c54bd83ea0198c13433a1eba32401850d (diff) | |
| download | bcm5719-llvm-feea95c88468cadbbed4ca0526826a7d279f2f7d.tar.gz bcm5719-llvm-feea95c88468cadbbed4ca0526826a7d279f2f7d.zip | |
Add a way to get the context of any particular scope.
llvm-svn: 187212
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 750231658f1..369895ce568 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/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(); |

