Add an empty key for DebugLoc so that you can store an empty DebugLoc in a
authorNick Lewycky <nicholas@mxc.ca>
Wed, 6 Apr 2011 06:49:59 +0000 (06:49 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 6 Apr 2011 06:49:59 +0000 (06:49 +0000)
DenseMap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128994 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/DebugLoc.h
lib/VMCore/DebugLoc.cpp

index 764591cfeded5b722d75d6ac9ec08a4a3a5e0a13..8d19e300ec2557fd0b4c58520567d8e4e9754657 100644 (file)
@@ -27,11 +27,19 @@ namespace llvm {
   class DebugLoc {
     friend struct DenseMapInfo<DebugLoc>;
 
+    /// getEmptyKey() - A private constructor that returns an unknown that is
+    /// not equal to the tombstone key or DebugLoc().
+    static DebugLoc getEmptyKey() {
+      DebugLoc DL;
+      DL.LineCol = -1;
+      return DL;
+    }
+
     /// getTombstoneKey() - A private constructor that returns an unknown that
-    /// is distinguishable from the usual one.
+    /// is not equal to the empty key or DebugLoc().
     static DebugLoc getTombstoneKey() {
       DebugLoc DL;
-      DL.LineCol = -1;
+      DL.LineCol = -2;
       return DL;
     }
 
index cb077cb43745620796fc8b778517de6c3040ef88..35691627f49702441d095ebfb12fb5bab70ae4c2 100644 (file)
@@ -133,7 +133,7 @@ DebugLoc DebugLoc::getFromDILocation(MDNode *N) {
 //===----------------------------------------------------------------------===//
 
 DebugLoc DenseMapInfo<DebugLoc>::getEmptyKey() {
-  return DebugLoc();
+  return DebugLoc::getEmptyKey();
 }
 
 DebugLoc DenseMapInfo<DebugLoc>::getTombstoneKey() {