[Support/Hash functions] Change the `final()` and `result()` of the hashing functions...
authorArgyrios Kyrtzidis <kyrtzidis@apple.com>
Mon, 4 Apr 2022 23:48:30 +0000 (16:48 -0700)
committerArgyrios Kyrtzidis <kyrtzidis@apple.com>
Wed, 6 Apr 2022 04:38:06 +0000 (21:38 -0700)
commit330268ba346b679af786879d8f696c8c412a40eb
tree63cfc32052a65a937a326092c138d8b6086b355a
parentacfc785c0ef65d4177ed43ad4fb5c7c205904810
[Support/Hash functions] Change the `final()` and `result()` of the hashing functions to return an array of bytes

Returning `std::array<uint8_t, N>` is better ergonomics for the hashing functions usage, instead of a `StringRef`:

* When returning `StringRef`, client code is "jumping through hoops" to do string manipulations instead of dealing with fixed array of bytes directly, which is more natural
* Returning `std::array<uint8_t, N>` avoids the need for the hasher classes to keep a field just for the purpose of wrapping it and returning it as a `StringRef`

As part of this patch also:

* Introduce `TruncatedBLAKE3` which is useful for using BLAKE3 as the hasher type for `HashBuilder` with non-default hash sizes.
* Make `MD5Result` inherit from `std::array<uint8_t, 16>` which improves & simplifies its API.

Differential Revision: https://reviews.llvm.org/D123100
29 files changed:
bolt/lib/Core/DebugData.cpp
clang/include/clang/Basic/Module.h
clang/lib/Serialization/ASTWriter.cpp
lld/MachO/SyntheticSections.cpp
llvm/include/llvm/Support/BLAKE3.h
llvm/include/llvm/Support/HashBuilder.h
llvm/include/llvm/Support/MD5.h
llvm/include/llvm/Support/SHA1.h
llvm/include/llvm/Support/SHA256.h
llvm/include/llvm/Support/raw_sha1_ostream.h
llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/DebugInfo/CodeView/TypeHashing.cpp
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/MC/MCDwarf.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/ObjCopy/MachO/MachOWriter.cpp
llvm/lib/Support/BLAKE3/README.md
llvm/lib/Support/MD5.cpp
llvm/lib/Support/SHA1.cpp
llvm/lib/Support/SHA256.cpp
llvm/unittests/Support/BLAKE3Test.cpp
llvm/unittests/Support/HashBuilderTest.cpp
llvm/unittests/Support/MD5Test.cpp
llvm/unittests/Support/SHA256.cpp
llvm/unittests/Support/raw_sha1_ostream_test.cpp
mlir/lib/Pass/IRPrinting.cpp