Add DebugLoc field and simple accessors.
[oota-llvm.git] / include / llvm / CodeGen / DebugLoc.h
index b6097afe306dbbdd664a91237645c31733324247..89c51c443b05f2b696b12c1d6bd7bdb0d209ef39 100644 (file)
@@ -33,16 +33,21 @@ namespace llvm {
     unsigned Idx;
 
   public:
-    DebugLoc() : Idx(~0U) {}
+    DebugLoc() : Idx(~0U) {}  // Defaults to invalid.
 
-    static DebugLoc getNoDebugLoc()   { DebugLoc L; L.Idx = 0;   return L; }
+    static DebugLoc getUnknownLoc()   { DebugLoc L; L.Idx = 0;   return L; }
     static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
 
-    bool isInvalid() { return Idx == ~0U; }
-    bool isUnknown() { return Idx == 0; }
+    // isInvalid - Return true if the DebugLoc is invalid.
+    bool isInvalid() const { return Idx == ~0U; }
+
+    // isUnknown - Return true if there is no debug info for the SDNode /
+    // MachineInstr.
+    bool isUnknown() const { return Idx == 0; }
   };
 
-  struct DebugLocTupleDenseMapInfo {
+  // Partially specialize DenseMapInfo for DebugLocTyple.
+  template<>  struct DenseMapInfo<DebugLocTuple> {
     static inline DebugLocTuple getEmptyKey() {
       return DebugLocTuple(~0U, ~0U, ~0U);
     }
@@ -63,24 +68,18 @@ namespace llvm {
     static bool isPod() { return true; }
   };
 
-  typedef DenseMap<DebugLocTuple, unsigned, DebugLocTupleDenseMapInfo>
-    DebugIdMapType;
-    
   /// DebugLocTracker - This class tracks debug location information.
   ///
   struct DebugLocTracker {
-    // NumDebugLocations - Size of the DebugLocations vector.
-    unsigned NumDebugLocations;
-
     // DebugLocations - A vector of unique DebugLocTuple's.
     //
     std::vector<DebugLocTuple> DebugLocations;
 
     // DebugIdsMap - This maps DebugLocTuple's to indices into
     // DebugLocations vector.
-    DebugIdMapType DebugIdMap;
+    DenseMap<DebugLocTuple, unsigned> DebugIdMap;
 
-    DebugLocTracker() : NumDebugLocations(0) {}
+    DebugLocTracker() {}
 
     ~DebugLocTracker() {
       DebugLocations.clear();