Skip to content

Commit 2ffa369

Browse files
author
David Ungar
committed
Catch conversion failure in Fingerprint
1 parent fcbc2b4 commit 2ffa369

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Basic/Fingerprint.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ Fingerprint Fingerprint::fromString(StringRef value) {
4141
std::istringstream s(value.drop_front(Fingerprint::DIGEST_LENGTH/2).str());
4242
s >> std::hex >> fp.core.second;
4343
}
44+
if (value != fp.getRawValue()) {
45+
llvm::errs() << "Fingerprint conversion failed; perhaps '" << value << "' is not a hex number";
46+
llvm::errs().flush();
47+
exit(1);
48+
}
4449
return fp;
4550
}
4651

@@ -49,6 +54,5 @@ llvm::SmallString<Fingerprint::DIGEST_LENGTH> Fingerprint::getRawValue() const {
4954
llvm::raw_svector_ostream Res(Str);
5055
Res << llvm::format_hex_no_prefix(core.first, 16);
5156
Res << llvm::format_hex_no_prefix(core.second, 16);
52-
assert(*this == Fingerprint::fromString(Str));
5357
return Str;
5458
}

0 commit comments

Comments
 (0)