Skip to content

Commit c987950

Browse files
[NFC][SampleFDO] Re-apply "In text sample prof reader, report more concrete parsing errors for different line types" (#155124)
Re-apply #154885 with a fix to initialize `LineTy` before calling `ParseLine`.
1 parent 9274200 commit c987950

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

llvm/lib/ProfileData/SampleProfReader.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,23 @@ std::error_code SampleProfileReaderText::readImpl() {
375375
StringRef FName;
376376
DenseMap<StringRef, uint64_t> TargetCountMap;
377377
uint32_t Depth, LineOffset, Discriminator;
378-
LineType LineTy;
378+
LineType LineTy = LineType::BodyProfile;
379379
uint64_t FunctionHash = 0;
380380
uint32_t Attributes = 0;
381381
bool IsFlat = false;
382382
if (!ParseLine(*LineIt, LineTy, Depth, NumSamples, LineOffset,
383383
Discriminator, FName, TargetCountMap, FunctionHash,
384384
Attributes, IsFlat)) {
385-
reportError(LineIt.line_number(),
386-
"Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found " +
387-
*LineIt);
385+
switch (LineTy) {
386+
case LineType::Metadata:
387+
reportError(LineIt.line_number(),
388+
"Cannot parse metadata: " + *LineIt);
389+
break;
390+
default:
391+
reportError(LineIt.line_number(),
392+
"Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found " +
393+
*LineIt);
394+
}
388395
return sampleprof_error::malformed;
389396
}
390397
if (LineTy != LineType::Metadata && Depth == DepthMetadata) {

0 commit comments

Comments
 (0)