Skip to content

Commit

Permalink
SHA1.h - remove unnecessary ArrayRef.h/StringRef.h includes. NFC.
Browse files Browse the repository at this point in the history
By moving the update(StringRef) wrapper into SHA1.cpp we can depend just on system headers.
  • Loading branch information
RKSimon committed Apr 21, 2020
1 parent f5b0591 commit 75aeb53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 2 additions & 7 deletions llvm/include/llvm/Support/SHA1.h
Expand Up @@ -15,14 +15,12 @@
#ifndef LLVM_SUPPORT_SHA1_H
#define LLVM_SUPPORT_SHA1_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"

#include <array>
#include <cstdint>

namespace llvm {
template <typename T> class ArrayRef;
class StringRef;

/// A class that wrap the SHA1 algorithm.
class SHA1 {
Expand All @@ -36,10 +34,7 @@ class SHA1 {
void update(ArrayRef<uint8_t> Data);

/// Digest more data.
void update(StringRef Str) {
update(ArrayRef<uint8_t>((uint8_t *)const_cast<char *>(Str.data()),
Str.size()));
}
void update(StringRef Str);

/// Return a reference to the current raw 160-bits SHA1 for the digested data
/// since the last call to init(). This call will add data to the internal
Expand Down
11 changes: 8 additions & 3 deletions llvm/lib/Support/SHA1.cpp
Expand Up @@ -16,13 +16,13 @@

#include "llvm/Support/SHA1.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Host.h"
using namespace llvm;

#include <stdint.h>
#include <string.h>

using namespace llvm;

#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
#define SHA_BIG_ENDIAN
#endif
Expand Down Expand Up @@ -238,6 +238,11 @@ void SHA1::update(ArrayRef<uint8_t> Data) {
addUncounted(C);
}

void SHA1::update(StringRef Str) {
update(
ArrayRef<uint8_t>((uint8_t *)const_cast<char *>(Str.data()), Str.size()));
}

void SHA1::pad() {
// Implement SHA-1 padding (fips180-2 5.1.1)

Expand Down

0 comments on commit 75aeb53

Please sign in to comment.