ForceFunctionAttrs: Use reportFatalUsageError (#139473)

This commit is contained in:
Matt Arsenault 2025-05-15 15:00:05 +02:00 committed by GitHub
parent 6090c0e0ee
commit 43db72d56d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -91,8 +91,12 @@ PreservedAnalyses ForceFunctionAttrsPass::run(Module &M,
bool Changed = false;
if (!CSVFilePath.empty()) {
auto BufferOrError = MemoryBuffer::getFileOrSTDIN(CSVFilePath);
if (!BufferOrError)
report_fatal_error("Cannot open CSV file.");
if (!BufferOrError) {
std::error_code EC = BufferOrError.getError();
M.getContext().emitError("cannot open CSV file: " + EC.message());
return PreservedAnalyses::all();
}
StringRef Buffer = BufferOrError.get()->getBuffer();
auto MemoryBuffer = MemoryBuffer::getMemBuffer(Buffer);
line_iterator It(*MemoryBuffer);

View File

@ -0,0 +1,6 @@
; RUN: not opt -disable-output -passes='forceattrs' -forceattrs-csv-path="%S/CannotOpenFile.csv" %s 2>&1 | FileCheck -DMSG=%errc_ENOENT %s
; CHECK: error: cannot open CSV file: [[MSG]]
define void @first_function() {
ret void
}