NOLINT and document use of StringLiteral::data() which subclasses StringRef (#7757)

StringRef::data() is problematic to call, but StringLiteral is always
NUL-terminated, so data() gives a valid C string.
This commit is contained in:
Dana Jansens
2026-09-10 22:00:36 +00:00
committed by GitHub
parent 8732bd9de1
commit e87831373f
+3
View File
@@ -487,6 +487,9 @@ auto Emitter<LocT>::Builder::FormatFn(const Message& message,
"Argument count mismatch on {0}: {1} != {2}", message.kind,
message.format_args.size(), sizeof...(Args));
return llvm::formatv(
// `format` is a StringLiteral which is always NUL terminated, so data()
// is okay here. Too bad there's no c_str() method available.
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
message.format.data(),
llvm::any_cast<
typename Internal::DiagnosticTypeForArg<Args>::StorageType>(