Provide a way to extract location info from DILocation.
authorDevang Patel <dpatel@apple.com>
Wed, 16 Sep 2009 18:20:05 +0000 (18:20 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 16 Sep 2009 18:20:05 +0000 (18:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82064 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/DebugInfo.h
lib/Analysis/DebugInfo.cpp

index b962d136deb76ac33dfa264be91f3767e701b5c2..b4e0fc323259e2030f1eb23d624c51cc2e812bd5 100644 (file)
@@ -669,6 +669,11 @@ namespace llvm {
   DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI,
                                 DebugLocTracker &DebugLocInfo);
 
+  /// ExtractDebugLocation - Extract debug location information 
+  /// from DILocation.
+  DebugLoc ExtractDebugLocation(DILocation &Loc,
+                                DebugLocTracker &DebugLocInfo);
+
   /// ExtractDebugLocation - Extract debug location information 
   /// from llvm.dbg.func_start intrinsic.
   DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,
index d09704f303927f535e12c137b57056a24cc330bc..78cbad87f4320f5791a1f7c857774d0fac45a0fe 100644 (file)
@@ -1209,6 +1209,29 @@ namespace llvm {
     return DebugLoc::get(Id);
   }
 
+  /// ExtractDebugLocation - Extract debug location information 
+  /// from DILocation.
+  DebugLoc ExtractDebugLocation(DILocation &Loc,
+                                DebugLocTracker &DebugLocInfo) {
+    DebugLoc DL;
+    MDNode *Context = Loc.getScope().getNode();
+
+    // If this location is already tracked then use it.
+    DebugLocTuple Tuple(Context, Loc.getLineNumber(),
+                       Loc.getColumnNumber());
+    DenseMap<DebugLocTuple, unsigned>::iterator II
+      = DebugLocInfo.DebugIdMap.find(Tuple);
+    if (II != DebugLocInfo.DebugIdMap.end())
+      return DebugLoc::get(II->second);
+
+    // Add a new location entry.
+    unsigned Id = DebugLocInfo.DebugLocations.size();
+    DebugLocInfo.DebugLocations.push_back(Tuple);
+    DebugLocInfo.DebugIdMap[Tuple] = Id;
+    
+    return DebugLoc::get(Id);
+  }
+
   /// ExtractDebugLocation - Extract debug location information 
   /// from llvm.dbg.func_start intrinsic.
   DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,