From 78faee066437605d57f61c70bbbb4a1ed24bb7e9 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 22 Sep 2009 03:34:53 +0000 Subject: Switch FoldingSet::AddString to StringRef based API. - This also fixes a dereference of std::string::end, which makes MSVC unhappy and was causing all the static analyzer clang tests to fail. llvm-svn: 82517 --- llvm/lib/Support/FoldingSet.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'llvm/lib/Support/FoldingSet.cpp') diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp index 187ecdb28b4..954dc77dff1 100644 --- a/llvm/lib/Support/FoldingSet.cpp +++ b/llvm/lib/Support/FoldingSet.cpp @@ -63,14 +63,14 @@ void FoldingSetNodeID::AddInteger(unsigned long long I) { Bits.push_back(unsigned(I >> 32)); } -void FoldingSetNodeID::AddString(const char *String, const char *End) { - unsigned Size = static_cast(End - String); +void FoldingSetNodeID::AddString(StringRef String) { + unsigned Size = String.size(); Bits.push_back(Size); if (!Size) return; unsigned Units = Size / 4; unsigned Pos = 0; - const unsigned *Base = (const unsigned *)String; + const unsigned *Base = (const unsigned*) String.data(); // If the string is aligned do a bulk transfer. if (!((intptr_t)Base & 3)) { @@ -100,14 +100,6 @@ void FoldingSetNodeID::AddString(const char *String, const char *End) { Bits.push_back(V); } -void FoldingSetNodeID::AddString(const char *String) { - AddString(String, String + strlen(String)); -} - -void FoldingSetNodeID::AddString(const std::string &String) { - AddString(&*String.begin(), &*String.end()); -} - /// ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to /// lookup the node in the FoldingSetImpl. unsigned FoldingSetNodeID::ComputeHash() const { -- cgit v1.2.3