diff options
Diffstat (limited to 'llvm/tools/llvm-cov/gcov.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/gcov.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/llvm/tools/llvm-cov/gcov.cpp b/llvm/tools/llvm-cov/gcov.cpp index 8a00ff64711fb..7a1dbbfe9338b 100644 --- a/llvm/tools/llvm-cov/gcov.cpp +++ b/llvm/tools/llvm-cov/gcov.cpp @@ -65,11 +65,11 @@ static void reportCoverage(StringRef SourceFile, StringRef ObjectDir, // Clear the filename to make it clear we didn't read anything. GCDA = "-"; } else { - GCOVBuffer GCDA_GB(GCDA_Buff.get().get()); - if (!GF.readGCDA(GCDA_GB)) { + GCOVBuffer gcda_buf(GCDA_Buff.get().get()); + if (!gcda_buf.readGCDAFormat()) + errs() << GCDA << ":not a gcov data file\n"; + else if (!GF.readGCDA(gcda_buf)) errs() << "Invalid .gcda File!\n"; - return; - } } if (DumpGCOV) @@ -77,7 +77,7 @@ static void reportCoverage(StringRef SourceFile, StringRef ObjectDir, FileInfo FI(Options); GF.collectLineCounts(FI); - FI.print(llvm::outs(), SourceFile, GCNO, GCDA); + FI.print(llvm::outs(), SourceFile, GCNO, GCDA, GF); } int gcovMain(int argc, const char *argv[]) { @@ -105,6 +105,16 @@ int gcovMain(int argc, const char *argv[]) { cl::desc("Show coverage for each function")); cl::alias FuncSummaryA("function-summaries", cl::aliasopt(FuncSummary)); + // Supported by gcov 4.9~8. gcov 9 (GCC r265587) removed --intermediate-format + // and -i was changed to mean --json-format. We consider this format still + // useful and support -i. + cl::opt<bool> Intermediate( + "intermediate-format", cl::init(false), + cl::desc("Output .gcov in intermediate text format")); + cl::alias IntermediateA("i", cl::desc("Alias for --intermediate-format"), + cl::Grouping, cl::NotHidden, + cl::aliasopt(Intermediate)); + cl::opt<bool> NoOutput("n", cl::Grouping, cl::init(false), cl::desc("Do not output any .gcov files")); cl::alias NoOutputA("no-output", cl::aliasopt(NoOutput)); @@ -119,6 +129,10 @@ int gcovMain(int argc, const char *argv[]) { cl::desc("Preserve path components")); cl::alias PreservePathsA("preserve-paths", cl::aliasopt(PreservePaths)); + cl::opt<bool> UseStdout("t", cl::Grouping, cl::init(false), + cl::desc("Print to stdout")); + cl::alias UseStdoutA("stdout", cl::aliasopt(UseStdout)); + cl::opt<bool> UncondBranch("u", cl::Grouping, cl::init(false), cl::desc("Display unconditional branch info " "(requires -b)")); @@ -140,8 +154,8 @@ int gcovMain(int argc, const char *argv[]) { cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n"); GCOV::Options Options(AllBlocks, BranchProb, BranchCount, FuncSummary, - PreservePaths, UncondBranch, LongNames, NoOutput, - HashFilenames); + PreservePaths, UncondBranch, Intermediate, LongNames, + NoOutput, UseStdout, HashFilenames); for (const auto &SourceFile : SourceFiles) reportCoverage(SourceFile, ObjectDir, InputGCNO, InputGCDA, DumpGCOV, |