Check for errors after reading a sample profile in llvm-profdata.
[oota-llvm.git] / tools / llvm-profdata / llvm-profdata.cpp
index 6fb48d8fad589c5c00586e8a2fbe011327c87ce2..23fa7b40f5014c07d23b4c97f8a66e2b5dc3cc34 100644 (file)
@@ -195,7 +195,9 @@ static int showSampleProfile(std::string Filename, bool ShowCounts,
     exitWithError(EC.message(), Filename);
 
   auto Reader = std::move(ReaderOrErr.get());
-  Reader->read();
+  if (std::error_code EC = Reader->read())
+    exitWithError(EC.message(), Filename);
+
   if (ShowAllFunctions || ShowFunction.empty())
     Reader->dump(OS);
   else