[llvm-commits] [llvm] r128994 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp

Nick Lewycky nicholas at mxc.ca
Tue Apr 5 23:49:59 PDT 2011


Author: nicholas
Date: Wed Apr  6 01:49:59 2011
New Revision: 128994

URL: http://llvm.org/viewvc/llvm-project?rev=128994&view=rev
Log:
Add an empty key for DebugLoc so that you can store an empty DebugLoc in a
DenseMap.

Modified:
    llvm/trunk/include/llvm/Support/DebugLoc.h
    llvm/trunk/lib/VMCore/DebugLoc.cpp

Modified: llvm/trunk/include/llvm/Support/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=128994&r1=128993&r2=128994&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DebugLoc.h (original)
+++ llvm/trunk/include/llvm/Support/DebugLoc.h Wed Apr  6 01:49:59 2011
@@ -27,11 +27,19 @@
   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;
     }
 

Modified: llvm/trunk/lib/VMCore/DebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugLoc.cpp?rev=128994&r1=128993&r2=128994&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/DebugLoc.cpp (original)
+++ llvm/trunk/lib/VMCore/DebugLoc.cpp Wed Apr  6 01:49:59 2011
@@ -133,7 +133,7 @@
 //===----------------------------------------------------------------------===//
 
 DebugLoc DenseMapInfo<DebugLoc>::getEmptyKey() {
-  return DebugLoc();
+  return DebugLoc::getEmptyKey();
 }
 
 DebugLoc DenseMapInfo<DebugLoc>::getTombstoneKey() {





More information about the llvm-commits mailing list