iterator end() const { return Data + Length; }
+ const unsigned char *bytes_begin() const {
+ return reinterpret_cast<const unsigned char *>(begin());
+ }
+ const unsigned char *bytes_end() const {
+ return reinterpret_cast<const unsigned char *>(end());
+ }
+
/// @}
/// @name String Operations
/// @{
/// \brief Pointer to one byte past the end of the string.
iterator end() const { return getString().end(); }
+ const unsigned char *bytes_begin() const { return getString().bytes_begin(); }
+ const unsigned char *bytes_end() const { return getString().bytes_end(); }
+
/// \brief Methods for support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDStringKind;
}
// Code: [strchar x N]
- Record.append(MDS->begin(), MDS->end());
+ Record.append(MDS->bytes_begin(), MDS->bytes_end());
// Emit the finished record.
Stream.EmitRecord(bitc::METADATA_STRING, Record, MDSAbbrev);
--- /dev/null
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; PR21882: confirm we don't crash when high bits are set in a character in a
+; metadata string.
+
+; CHECK: !name = !{!0}
+!name = !{!0}
+; CHECK: !0 = metadata !{metadata !"\80"}
+!0 = metadata !{metadata !"\80"}