Skip to content

Commit d2bcd58

Browse files
authored
[profdata] Consume reader error if returned early (#163671)
1 parent 5d9df8f commit d2bcd58

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/tools/llvm-profdata/llvm-profdata.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "llvm/ADT/ScopeExit.h"
1314
#include "llvm/ADT/SmallSet.h"
1415
#include "llvm/ADT/SmallVector.h"
1516
#include "llvm/ADT/StringRef.h"
@@ -778,6 +779,12 @@ loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
778779
// we have more non-fatal errors from InstrProfReader in the future. How
779780
// should this interact with different -failure-mode?
780781
std::optional<std::pair<Error, std::string>> ReaderWarning;
782+
auto ReaderWarningScope = llvm::make_scope_exit([&] {
783+
// If we hit a different error we may still have an error in ReaderWarning.
784+
// Consume it now to avoid an assert
785+
if (ReaderWarning)
786+
consumeError(std::move(ReaderWarning->first));
787+
});
781788
auto Warn = [&](Error E) {
782789
if (ReaderWarning) {
783790
consumeError(std::move(E));

0 commit comments

Comments
 (0)