aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-10-05 18:03:19 +0000
committerDevang Patel <dpatel@apple.com>2009-10-05 18:03:19 +0000
commitf84548db63ca5ceea0381a7bfc9e924cddc1cc3f (patch)
tree826bbe3f0d13da25ff7175ccf1fcf37fce0b0743 /lib/CodeGen/AsmPrinter/DwarfDebug.cpp
parentc6f69e94fa46f585b59bb9d7ace3224b0e638c95 (diff)
Gracefully handle various scopes while recording source line info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83317 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index bbaf1ad1aa..e364c0d9bc 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1958,16 +1958,33 @@ unsigned DwarfDebug::RecordSourceLine(Value *V, unsigned Line, unsigned Col) {
/// label. Returns a unique label ID used to generate a label and provide
/// correspondence to the source line list.
unsigned DwarfDebug::RecordSourceLine(unsigned Line, unsigned Col,
- MDNode *Scope) {
+ MDNode *S) {
if (!MMI)
return 0;
if (TimePassesIsEnabled)
DebugTimer->startTimer();
- DICompileUnit CU(Scope);
- unsigned Src = GetOrCreateSourceID(CU.getDirectory(),
- CU.getFilename());
+ const char *Dir = NULL;
+ const char *Fn = NULL;
+
+ DIDescriptor Scope(S);
+ if (Scope.isCompileUnit()) {
+ DICompileUnit CU(S);
+ Dir = CU.getDirectory();
+ Fn = CU.getFilename();
+ } else if (Scope.isSubprogram()) {
+ DISubprogram SP(S);
+ Dir = SP.getDirectory();
+ Fn = SP.getFilename();
+ } else if (Scope.isLexicalBlock()) {
+ DILexicalBlock DB(S);
+ Dir = DB.getDirectory();
+ Fn = DB.getFilename();
+ } else
+ assert (0 && "Unexpected scope info");
+
+ unsigned Src = GetOrCreateSourceID(Dir, Fn);
unsigned ID = MMI->NextLabelID();
Lines.push_back(SrcLineInfo(Line, Col, Src, ID));