[llvm] r182692 - ArrayRef-ize MD5 and clean up a few variable names.

Sean Silva silvas at purdue.edu
Fri May 24 17:32:11 PDT 2013


On Fri, May 24, 2013 at 5:08 PM, Eric Christopher <echristo at gmail.com>wrote:

> Author: echristo
> Date: Fri May 24 18:08:17 2013
> New Revision: 182692
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182692&view=rev
> Log:
> ArrayRef-ize MD5 and clean up a few variable names.
> Add a stringize method to make dumping a bit easier, and add a testcase
> exercising a few different paths.
>
> Added:
>     llvm/trunk/unittests/Support/MD5Test.cpp
> Modified:
>     llvm/trunk/include/llvm/Support/MD5.h
>     llvm/trunk/lib/Support/MD5.cpp
>
> Modified: llvm/trunk/include/llvm/Support/MD5.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MD5.h?rev=182692&r1=182691&r2=182692&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/MD5.h (original)
> +++ llvm/trunk/include/llvm/Support/MD5.h Fri May 24 18:08:17 2013
> @@ -28,10 +28,13 @@
>  #ifndef LLVM_SYSTEM_MD5_H
>  #define LLVM_SYSTEM_MD5_H
>
> +#include "llvm/ADT/SmallString.h"
>  #include "llvm/Support/DataTypes.h"
>
>  namespace llvm {
>
> +template <typename T> class ArrayRef;
> +
>

Is it legit to forward-declare this and then take an ArrayRef by value?


>  class MD5 {
>    // Any 32-bit or wider unsigned integer data type will do.
>    typedef uint32_t MD5_u32plus;
> @@ -41,17 +44,21 @@ class MD5 {
>    unsigned char buffer[64];
>    MD5_u32plus block[16];
>
> - public:
> +public:
> +  typedef unsigned char MD5Result[16];
> +
>    MD5();
>
>    /// \brief Updates the hash for arguments provided.
> -  void Update(void *data, unsigned long size);
> +  void update(ArrayRef<unsigned char> Data);
>
>    /// \brief Finishes off the hash and puts the result in result.
> -  void Final(unsigned char *result);
> +  void final(MD5Result &result);
> +
> +  static void stringifyResult(MD5Result &Res, SmallString<32> &Str);


stringifyResult could use a comment describing what it does. My best guess
is that it produces an ASCII hex digest, but it's not clear. If that is
what it does, then just call it something with "ASCIIHexDigest" in the
name. Also, can it be a free function?


Side note: on my system, adding the SmallString.h include pulls in over 25K
lines of code :( (it's mostly through SmallVector.h) sigh...

-- Sean Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130524/cc9ec21d/attachment.html>


More information about the llvm-commits mailing list