Skip to content

Commit 52b0e3f

Browse files
[NFC][SampleFDO] In text sample prof reader, report dreport more concrete parsing errors for different line types (llvm#154885)
The format `'NUM[.NUM]: NUM[ mangled_name:NUM]*'` applies for most line types except metadata ones.
1 parent cda317a commit 52b0e3f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

llvm/lib/ProfileData/SampleProfReader.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,16 @@ std::error_code SampleProfileReaderText::readImpl() {
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)