Check for errors after reading a sample profile in llvm-profdata.
authorDiego Novillo <dnovillo@google.com>
Thu, 17 Sep 2015 00:17:21 +0000 (00:17 +0000)
committerDiego Novillo <dnovillo@google.com>
Thu, 17 Sep 2015 00:17:21 +0000 (00:17 +0000)
After reading the profile, check if the reader returned any errors
before showing the profile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247873 91177308-0d34-0410-b5e6-96231b3b80d8

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