Argyrios Kyrtzidis | a343764 | 2009-05-20 22:57:17 +0000 | [diff] [blame] | 1 | //===-- DebugLoc.cpp ------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Implementation for DebugScopeTracker. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/CodeGen/DebugLoc.h" |
| 15 | #include "llvm/CodeGen/MachineFunction.h" |
| 16 | using namespace llvm; |
| 17 | |
| 18 | /// EnterDebugScope - Start a new debug scope. ScopeGV can be a DISubprogram |
| 19 | /// or a DIBlock. |
| 20 | void DebugScopeTracker::EnterDebugScope(GlobalVariable *ScopeGV, |
| 21 | MachineFunction &MF) { |
| 22 | assert(ScopeGV && "GlobalVariable for scope is null!"); |
| 23 | CurScope = MF.CreateDebugScope(ScopeGV, CurScope); |
| 24 | } |
| 25 | |
| 26 | /// ExitDebugScope - "Pop" a DISubprogram or a DIBlock. |
| 27 | void DebugScopeTracker::ExitDebugScope(GlobalVariable *ScopeGV, |
| 28 | MachineFunction &MF) { |
| 29 | assert(ScopeGV && "GlobalVariable for scope is null!"); |
| 30 | assert(!CurScope.isInvalid() && "Mismatched region.end ?"); |
| 31 | // We may have skipped a region.end because it was in an unreachable block. |
| 32 | // Go up the scope chain until we reach the scope that ScopeGV points to. |
| 33 | DebugScopeInfo DSI; |
| 34 | do { |
| 35 | DSI = MF.getDebugScopeInfo(CurScope); |
| 36 | CurScope = DSI.Parent; |
| 37 | } while (!DSI.Parent.isInvalid() && DSI.GV != ScopeGV); |
| 38 | } |