Simplify memory management with std::unique_ptr.
[oota-llvm.git] / tools / llvm-cov / llvm-cov.cpp
index 02f4b7221699a56617362f713cbe365301a224a8..0a64d76c3741c87a82e3096aedc7dbbcb70fe440 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/GCOV.h"
 #include "llvm/Support/ManagedStatic.h"
@@ -20,7 +21,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
-#include "llvm/Support/system_error.h"
+#include <system_error>
 using namespace llvm;
 
 static cl::opt<std::string> SourceFile(cl::Positional, cl::Required,
@@ -47,6 +48,10 @@ static cl::opt<bool> FuncSummary("f", cl::Grouping, cl::init(false),
                                  cl::desc("Show coverage for each function"));
 static cl::alias FuncSummaryA("function-summaries", cl::aliasopt(FuncSummary));
 
+static cl::opt<bool> NoOutput("n", cl::Grouping, cl::init(false),
+                              cl::desc("Do not output any .gcov files"));
+static cl::alias NoOutputA("no-output", cl::aliasopt(NoOutput));
+
 static cl::opt<std::string>
 ObjectDir("o", cl::value_desc("DIR|FILE"), cl::init(""),
           cl::desc("Find objects in DIR or based on FILE's path"));
@@ -100,7 +105,7 @@ int main(int argc, char **argv) {
   GCOVFile GF;
 
   std::unique_ptr<MemoryBuffer> GCNO_Buff;
-  if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
+  if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
     errs() << InputGCNO << ": " << ec.message() << "\n";
     return 1;
   }
@@ -111,7 +116,7 @@ int main(int argc, char **argv) {
   }
 
   std::unique_ptr<MemoryBuffer> GCDA_Buff;
-  if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
+  if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
     if (ec != errc::no_such_file_or_directory) {
       errs() << InputGCDA << ": " << ec.message() << "\n";
       return 1;
@@ -130,7 +135,7 @@ int main(int argc, char **argv) {
     GF.dump();
 
   GCOVOptions Options(AllBlocks, BranchProb, BranchCount, FuncSummary,
-                      PreservePaths, UncondBranch, LongNames);
+                      PreservePaths, UncondBranch, LongNames, NoOutput);
   FileInfo FI(Options);
   GF.collectLineCounts(FI);
   FI.print(SourceFile, InputGCNO, InputGCDA);