File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -67,12 +67,19 @@ std::optional<size_t> CachedCommandAdaptor::searchComgrTmpModel(StringRef S) {
67
67
return Pos;
68
68
}
69
69
70
+ void CachedCommandAdaptor::addUInt (CachedCommandAdaptor::HashAlgorithm &H,
71
+ uint64_t I) {
72
+ uint8_t Bytes[sizeof (I)];
73
+ memcpy (&Bytes, &I, sizeof (I));
74
+ H.update (Bytes);
75
+ }
76
+
70
77
void CachedCommandAdaptor::addString (CachedCommandAdaptor::HashAlgorithm &H,
71
78
StringRef S) {
72
79
// hash size + contents to avoid collisions
73
80
// for example, we have to ensure that the result of hashing "AA" "BB" is
74
81
// different from "A" "ABB"
75
- H. update ( S.size ());
82
+ addUInt (H, S.size ());
76
83
H.update (S);
77
84
}
78
85
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ class CachedCommandAdaptor {
39
39
40
40
// helper to work around the comgr-xxxxx string appearing in files
41
41
static void addFileContents (HashAlgorithm &H, llvm::StringRef Buf);
42
+ static void addUInt (HashAlgorithm &H, uint64_t I);
42
43
static void addString (HashAlgorithm &H, llvm::StringRef S);
43
44
static std::optional<size_t > searchComgrTmpModel (llvm::StringRef S);
44
45
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ CachedCommandAdaptor::ActionClass UnbundleCommand::getClass() const {
122
122
}
123
123
124
124
void UnbundleCommand::addOptionsIdentifier (HashAlgorithm &H) const {
125
- H. update ( Config.TargetNames .size ());
125
+ addUInt (H, Config.TargetNames .size ());
126
126
for (StringRef Target : Config.TargetNames ) {
127
127
CachedCommandAdaptor::addString (H, Target);
128
128
}
@@ -150,8 +150,8 @@ Error UnbundleCommand::addInputIdentifier(HashAlgorithm &H) const {
150
150
// contents should give the same result, regardless of the compression
151
151
// algorithm or header version. Since the hash used by the offload bundler is
152
152
// not a cryptographic hash, we also add the uncompressed file size.
153
- H. update ( MaybeHeader->Hash );
154
- H. update ( MaybeHeader->UncompressedFileSize );
153
+ addUInt (H, MaybeHeader->Hash );
154
+ addUInt (H, MaybeHeader->UncompressedFileSize );
155
155
return Error::success ();
156
156
}
157
157
You can’t perform that action at this time.
0 commit comments