diff options
| author | Devang Patel <dpatel@apple.com> | 2009-10-05 18:03:19 +0000 | 
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-10-05 18:03:19 +0000 | 
| commit | 2089d161405e88985408cdb1ab888e39ce9b9b58 (patch) | |
| tree | b4d4a4dab36b402e4e361a3fb3a3777a84099e62 /llvm/lib | |
| parent | d7eb7179a2ccf65f43eae4e7cae0617f502cdef5 (diff) | |
| download | bcm5719-llvm-2089d161405e88985408cdb1ab888e39ce9b9b58.tar.gz bcm5719-llvm-2089d161405e88985408cdb1ab888e39ce9b9b58.zip  | |
Gracefully handle various scopes while recording source line info.
llvm-svn: 83317
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 25 | 
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index bbaf1ad1aae..e364c0d9bce 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/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));  | 

