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: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/lib/Frontend/ASTUnit.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=298322&r1=298321&r2=298322&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Mon Mar 20 18:33:18 2017 @@ -612,7 +612,7 @@ uint64_t PGOHash::finalize() { llvm::MD5::MD5Result Result; MD5.final(Result); using namespace llvm::support; - return endian::read<uint64_t, little, unaligned>(Result); + return Result.low(); } void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) { Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=298322&r1=298321&r2=298322&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original) +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Mar 20 18:33:18 2017 @@ -1252,7 +1252,7 @@ ASTUnit::PreambleFileHash::createForFile PreambleFileHash Result; Result.Size = Size; Result.ModTime = ModTime; - memset(Result.MD5, 0, sizeof(Result.MD5)); + Result.MD5 = {}; return Result; } @@ -1273,7 +1273,7 @@ namespace clang { bool operator==(const ASTUnit::PreambleFileHash &LHS, const ASTUnit::PreambleFileHash &RHS) { return LHS.Size == RHS.Size && LHS.ModTime == RHS.ModTime && - memcmp(LHS.MD5, RHS.MD5, sizeof(LHS.MD5)) == 0; + LHS.MD5 == RHS.MD5; } } // namespace clang _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits