Skip to content

Commit

Permalink
Avoid warnings caused by ignoring [[nodiscard]] return type
Browse files Browse the repository at this point in the history
Since LLVM 14, llvm::InstrProfWriter::write returns an llvm::Error
rather than void. Propagate potential errors back to the caller
to avoid triggering warnings
  • Loading branch information
vengaer authored and AlexDenisov committed Dec 5, 2022
1 parent 61903fd commit 459982e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/mull-runner/MergeInstProfile.cpp
@@ -1,5 +1,6 @@
#include "MergeInstProfile.h"
#include "mull/Diagnostics/Diagnostics.h"
#include <llvm/Config/llvm-config.h>
#include <llvm/ProfileData/InstrProfReader.h>
#include <llvm/ProfileData/InstrProfWriter.h>
#include <llvm/Support/raw_ostream.h>
Expand All @@ -25,6 +26,14 @@ bool mull::mergeRawInstProfile(Diagnostics &diagnostics, const std::string &inpu
diagnostics.warning("cannot save indexed profile data: "s + ec.message());
return false;
}

// Since LLVM 14, llvm::InstrProfWriter::write returns a [[nodiscard]]-attributed
// llvm::Error. Propagate potential errors back to the caller to avoid trigger
// unused warnings
#if LLVM_VERSION_MAJOR >= 14
return bool(writer.write(out));
#else
writer.write(out);
return true;
#endif
}

0 comments on commit 459982e

Please sign in to comment.