From: Nick Lewycky Date: Wed, 6 Apr 2011 06:49:59 +0000 (+0000) Subject: Add an empty key for DebugLoc so that you can store an empty DebugLoc in a X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4841121580df86b327013d1fab2a9339be487bce;p=oota-llvm.git Add an empty key for DebugLoc so that you can store an empty DebugLoc in a DenseMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128994 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h index 764591cfede..8d19e300ec2 100644 --- a/include/llvm/Support/DebugLoc.h +++ b/include/llvm/Support/DebugLoc.h @@ -27,11 +27,19 @@ namespace llvm { class DebugLoc { friend struct DenseMapInfo; + /// 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; } diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp index cb077cb4374..35691627f49 100644 --- a/lib/VMCore/DebugLoc.cpp +++ b/lib/VMCore/DebugLoc.cpp @@ -133,7 +133,7 @@ DebugLoc DebugLoc::getFromDILocation(MDNode *N) { //===----------------------------------------------------------------------===// DebugLoc DenseMapInfo::getEmptyKey() { - return DebugLoc(); + return DebugLoc::getEmptyKey(); } DebugLoc DenseMapInfo::getTombstoneKey() {