Skip to content

Commit a3865b8

Browse files
Check for the empty input.
1 parent a395c91 commit a3865b8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,16 @@ loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
747747
Filename);
748748
};
749749

750-
WC->Writer.addMemProfData(Reader->takeMemProfData(), MemProfError);
750+
auto MemProfData = Reader->takeMemProfData();
751+
752+
// Check for the empty input in case the YAML file is invalid.
753+
if (MemProfData.Records.empty()) {
754+
WC->Errors.emplace_back(
755+
make_error<StringError>("The profile is empty.", std::error_code()),
756+
Filename);
757+
}
758+
759+
WC->Writer.addMemProfData(std::move(MemProfData), MemProfError);
751760
return;
752761
}
753762

0 commit comments

Comments
 (0)