Skip to content

Commit f19f3f7

Browse files
[NFC]In text sample prof reader, report dreport more concrete parsing errors for different line types
1 parent 0319a79 commit f19f3f7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

llvm/lib/ProfileData/SampleProfReader.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ std::error_code SampleProfileReaderText::readImpl() {
357357
uint64_t NumSamples, NumHeadSamples;
358358
StringRef FName;
359359
if (!ParseHead(*LineIt, FName, NumSamples, NumHeadSamples)) {
360+
360361
reportError(LineIt.line_number(),
361362
"Expected 'mangled_name:NUM:NUM', found " + *LineIt);
362363
return sampleprof_error::malformed;
@@ -382,9 +383,16 @@ std::error_code SampleProfileReaderText::readImpl() {
382383
if (!ParseLine(*LineIt, LineTy, Depth, NumSamples, LineOffset,
383384
Discriminator, FName, TargetCountMap, FunctionHash,
384385
Attributes, IsFlat)) {
385-
reportError(LineIt.line_number(),
386-
"Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found " +
387-
*LineIt);
386+
switch (LineTy) {
387+
case LineType::Metadata:
388+
reportError(LineIt.line_number(),
389+
"Cannot parse metadata: " + *LineIt);
390+
break;
391+
default:
392+
reportError(LineIt.line_number(),
393+
"Expected 'NUM[.NUM]: NUM[ mangled_name:NUM]*', found " +
394+
*LineIt);
395+
}
388396
return sampleprof_error::malformed;
389397
}
390398
if (LineTy != LineType::Metadata && Depth == DepthMetadata) {

0 commit comments

Comments
 (0)