Commit 21661607 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

[llvm] 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.
parent b9b90bb5
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -411,7 +411,8 @@ public:
  const Elf_Shdr *getRelSection(DataRefImpl Rel) const {
    auto RelSecOrErr = EF.getSection(Rel.d.a);
    if (!RelSecOrErr)
      report_fatal_error(errorToErrorCode(RelSecOrErr.takeError()).message());
      report_fatal_error(
          Twine(errorToErrorCode(RelSecOrErr.takeError()).message()));
    return *RelSecOrErr;
  }

@@ -970,7 +971,8 @@ ELFObjectFile<ELFT>::section_rel_end(DataRefImpl Sec) const {
  // Error check sh_link here so that getRelocationSymbol can just use it.
  auto SymSecOrErr = EF.getSection(RelSec->sh_link);
  if (!SymSecOrErr)
    report_fatal_error(errorToErrorCode(SymSecOrErr.takeError()).message());
    report_fatal_error(
        Twine(errorToErrorCode(SymSecOrErr.takeError()).message()));

  RelData.d.b += S->sh_size / S->sh_entsize;
  return relocation_iterator(RelocationRef(RelData, this));
@@ -1059,7 +1061,7 @@ ELFObjectFile<ELFT>::getRel(DataRefImpl Rel) const {
  assert(getRelSection(Rel)->sh_type == ELF::SHT_REL);
  auto Ret = EF.template getEntry<Elf_Rel>(Rel.d.a, Rel.d.b);
  if (!Ret)
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
    report_fatal_error(Twine(errorToErrorCode(Ret.takeError()).message()));
  return *Ret;
}

@@ -1069,7 +1071,7 @@ ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
  assert(getRelSection(Rela)->sh_type == ELF::SHT_RELA);
  auto Ret = EF.template getEntry<Elf_Rela>(Rela.d.a, Rela.d.b);
  if (!Ret)
    report_fatal_error(errorToErrorCode(Ret.takeError()).message());
    report_fatal_error(Twine(errorToErrorCode(Ret.takeError()).message()));
  return *Ret;
}

+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix);
[[noreturn]] inline void ReportLastErrorFatal(const char *Msg) {
  std::string ErrMsg;
  MakeErrMsg(&ErrMsg, Msg);
  llvm::report_fatal_error(ErrMsg);
  llvm::report_fatal_error(Twine(ErrMsg));
}

template <typename HandleTraits>
+5 −4
Original line number Diff line number Diff line
@@ -1081,12 +1081,12 @@ void MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata(
  if (Error Err = IndexCursor.JumpToBit(
          GlobalMetadataBitPosIndex[ID - MDStringRef.size()]))
    report_fatal_error("lazyLoadOneMetadata failed jumping: " +
                       toString(std::move(Err)));
                       Twine(toString(std::move(Err))));
  Expected<BitstreamEntry> MaybeEntry = IndexCursor.advanceSkippingSubblocks();
  if (!MaybeEntry)
    // FIXME this drops the error on the floor.
    report_fatal_error("lazyLoadOneMetadata failed advanceSkippingSubblocks: " +
                       toString(MaybeEntry.takeError()));
                       Twine(toString(MaybeEntry.takeError())));
  BitstreamEntry Entry = MaybeEntry.get();
  ++NumMDRecordLoaded;
  if (Expected<unsigned> MaybeCode =
@@ -1094,9 +1094,10 @@ void MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata(
    if (Error Err =
            parseOneMetadata(Record, MaybeCode.get(), Placeholders, Blob, ID))
      report_fatal_error("Can't lazyload MD, parseOneMetadata: " +
                         toString(std::move(Err)));
                         Twine(toString(std::move(Err))));
  } else
    report_fatal_error("Can't lazyload MD: " + toString(MaybeCode.takeError()));
    report_fatal_error("Can't lazyload MD: " +
                       Twine(toString(MaybeCode.takeError())));
}

/// Ensure that all forward-references and placeholders are resolved.
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ static void reportTranslationError(MachineFunction &MF,
    R << (" (in function: " + MF.getName() + ")").str();

  if (TPC.isGlobalISelAbortEnabled())
    report_fatal_error(R.getMsg());
    report_fatal_error(Twine(R.getMsg()));
  else
    ORE.emit(R);
}
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ static void reportGISelDiagnostic(DiagnosticSeverity Severity,
    R << (" (in function: " + MF.getName() + ")").str();

  if (IsFatal)
    report_fatal_error(R.getMsg());
    report_fatal_error(Twine(R.getMsg()));
  else
    MORE.emit(R);
}
Loading