[clang] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine)

As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
This commit is contained in:
Simon Pilgrim 2021-10-06 11:23:26 +01:00
parent 78873840ff
commit b9b90bb542
6 changed files with 12 additions and 12 deletions

View File

@ -141,7 +141,7 @@ runCheckOnCode(StringRef Code, std::vector<ClangTidyError> *Errors = nullptr,
for (const auto &Error : DiagConsumer.take()) {
ErrorText += Error.Message.Message + "\n";
}
llvm::report_fatal_error(ErrorText);
llvm::report_fatal_error(llvm::Twine(ErrorText));
}
tooling::Replacements Fixes;

View File

@ -350,7 +350,7 @@ struct SavedStreamPosition {
~SavedStreamPosition() {
if (llvm::Error Err = Cursor.JumpToBit(Offset))
llvm::report_fatal_error(
"Cursor should always be able to go back, failed: " +
llvm::Twine("Cursor should always be able to go back, failed: ") +
toString(std::move(Err)));
}

View File

@ -58,7 +58,7 @@ ProfileSpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
std::string Error;
if (auto PSCL = create(Paths, VFS, Error))
return PSCL;
llvm::report_fatal_error(Error);
llvm::report_fatal_error(llvm::Twine(Error));
}
}

View File

@ -264,7 +264,7 @@ public:
std::string Error;
auto Triple = Ctx.getTargetInfo().getTriple();
if (!llvm::TargetRegistry::lookupTarget(Triple.getTriple(), Error))
llvm::report_fatal_error(Error);
llvm::report_fatal_error(llvm::Twine(Error));
// Emit the serialized Clang AST into its own section.
assert(Buffer->IsComplete && "serialization did not complete");

View File

@ -3851,7 +3851,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
Expected<unsigned> MaybeDeclCode = Record.readRecord(DeclsCursor, Code);
if (!MaybeDeclCode)
llvm::report_fatal_error(
"ASTReader::readDeclRecord failed reading decl code: " +
Twine("ASTReader::readDeclRecord failed reading decl code: ") +
toString(MaybeDeclCode.takeError()));
switch ((DeclCode)MaybeDeclCode.get()) {
case DECL_CONTEXT_LEXICAL:
@ -4236,12 +4236,12 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
if (llvm::Error JumpFailed = Cursor.JumpToBit(Offset))
// FIXME don't do a fatal error.
llvm::report_fatal_error(
"ASTReader::loadDeclUpdateRecords failed jumping: " +
Twine("ASTReader::loadDeclUpdateRecords failed jumping: ") +
toString(std::move(JumpFailed)));
Expected<unsigned> MaybeCode = Cursor.ReadCode();
if (!MaybeCode)
llvm::report_fatal_error(
"ASTReader::loadDeclUpdateRecords failed reading code: " +
Twine("ASTReader::loadDeclUpdateRecords failed reading code: ") +
toString(MaybeCode.takeError()));
unsigned Code = MaybeCode.get();
ASTRecordReader Record(*this, *F);
@ -4250,7 +4250,7 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
"Expected DECL_UPDATES record!");
else
llvm::report_fatal_error(
"ASTReader::loadDeclUpdateRecords failed reading rec code: " +
Twine("ASTReader::loadDeclUpdateRecords failed reading rec code: ") +
toString(MaybeCode.takeError()));
ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
@ -4317,14 +4317,14 @@ void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
SavedStreamPosition SavedPosition(Cursor);
if (llvm::Error JumpFailed = Cursor.JumpToBit(LocalOffset))
llvm::report_fatal_error(
"ASTReader::loadPendingDeclChain failed jumping: " +
Twine("ASTReader::loadPendingDeclChain failed jumping: ") +
toString(std::move(JumpFailed)));
RecordData Record;
Expected<unsigned> MaybeCode = Cursor.ReadCode();
if (!MaybeCode)
llvm::report_fatal_error(
"ASTReader::loadPendingDeclChain failed reading code: " +
Twine("ASTReader::loadPendingDeclChain failed reading code: ") +
toString(MaybeCode.takeError()));
unsigned Code = MaybeCode.get();
if (Expected<unsigned> MaybeRecCode = Cursor.readRecord(Code, Record))
@ -4332,7 +4332,7 @@ void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
"expected LOCAL_REDECLARATIONS record!");
else
llvm::report_fatal_error(
"ASTReader::loadPendingDeclChain failed reading rec code: " +
Twine("ASTReader::loadPendingDeclChain failed reading rec code: ") +
toString(MaybeCode.takeError()));
// FIXME: We have several different dispatches on decl kind here; maybe

View File

@ -170,7 +170,7 @@ CommonOptionsParser::CommonOptionsParser(
llvm::Error Err = init(argc, argv, Category, OccurrencesFlag, Overview);
if (Err) {
llvm::report_fatal_error(
"CommonOptionsParser: failed to parse command-line arguments. " +
Twine("CommonOptionsParser: failed to parse command-line arguments. ") +
llvm::toString(std::move(Err)));
}
}