[Lldb-commits] [lldb] r298322 - Add a function to MD5 a file's contents.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 20 16:33:19 PDT 2017


Author: zturner
Date: Mon Mar 20 18:33:18 2017
New Revision: 298322

URL: http://llvm.org/viewvc/llvm-project?rev=298322&view=rev
Log:
Add a function to MD5 a file's contents.

In doing so, clean up the MD5 interface a little.  Most
existing users only care about the lower 8 bytes of an MD5,
but for some users that care about the upper and lower,
there wasn't a good interface.  Furthermore, consumers
of the MD5 checksum were required to handle endianness
details on their own, so it seems reasonable to abstract
this into a nicer interface that just gives you the right
value.

Differential Revision: https://reviews.llvm.org/D31105

Modified:
    lldb/trunk/source/Host/common/FileSystem.cpp
    lldb/trunk/source/Utility/DataExtractor.cpp

Modified: lldb/trunk/source/Host/common/FileSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSystem.cpp?rev=298322&r1=298321&r2=298322&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/common/FileSystem.cpp Mon Mar 20 18:33:18 2017
@@ -67,9 +67,7 @@ bool FileSystem::CalculateMD5(const File
   if (!CalcMD5(file_spec, offset, length, md5_result))
     return false;
 
-  const auto uint64_res = reinterpret_cast<const uint64_t *>(md5_result);
-  high = uint64_res[0];
-  low = uint64_res[1];
+  std::tie(high, low) = md5_result.words();
 
   return true;
 }

Modified: lldb/trunk/source/Utility/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/DataExtractor.cpp?rev=298322&r1=298321&r2=298322&view=diff
==============================================================================
--- lldb/trunk/source/Utility/DataExtractor.cpp (original)
+++ lldb/trunk/source/Utility/DataExtractor.cpp Mon Mar 20 18:33:18 2017
@@ -1233,6 +1233,6 @@ void DataExtractor::Checksum(llvm::Small
   llvm::MD5::MD5Result result;
   md5.final(result);
 
-  dest.resize(16);
-  std::copy(result, result + 16, dest.begin());
+  dest.clear();
+  dest.append(result.Bytes.begin(), result.Bytes.end());
 }




More information about the lldb-commits mailing list