diff options
-rw-r--r-- | llvm/lib/ObjectYAML/YAML.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/ObjectYAML/YAML.cpp b/llvm/lib/ObjectYAML/YAML.cpp index 4c5137f94c0..6eba16e36c2 100644 --- a/llvm/lib/ObjectYAML/YAML.cpp +++ b/llvm/lib/ObjectYAML/YAML.cpp @@ -31,7 +31,7 @@ StringRef yaml::ScalarTraits<yaml::BinaryRef>::input(StringRef Scalar, void *, // TODO: Can we improve YAMLIO to permit a more accurate diagnostic here? // (e.g. a caret pointing to the offending character). for (unsigned I = 0, N = Scalar.size(); I != N; ++I) - if (!isxdigit(Scalar[I])) + if (!llvm::isHexDigit(Scalar[I])) return "BinaryRef hex string must contain only hex digits."; Val = yaml::BinaryRef(Scalar); return {}; @@ -43,8 +43,9 @@ void yaml::BinaryRef::writeAsBinary(raw_ostream &OS) const { return; } for (unsigned I = 0, N = Data.size(); I != N; I += 2) { - uint8_t Byte; - StringRef((const char *)&Data[I], 2).getAsInteger(16, Byte); + uint8_t Byte = llvm::hexDigitValue(Data[I]); + Byte <<= 4; + Byte |= llvm::hexDigitValue(Data[I + 1]); OS.write(Byte); } } |