From 9433c770f7cd72882fa33edf3b53dd62a23abc21 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 4 Feb 2014 06:41:39 +0000 Subject: llvm-cov: Ignore missing .gcda files When gcov is run without gcda data, it acts as if the counts are all zero and labels the file as - to indicate that there was no data. We should do the same. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200740 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-cov/llvm-cov.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tools/llvm-cov') diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp index f549891694..be8d1c9036 100644 --- a/tools/llvm-cov/llvm-cov.cpp +++ b/tools/llvm-cov/llvm-cov.cpp @@ -84,13 +84,18 @@ int main(int argc, char **argv) { OwningPtr GCDA_Buff; if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) { - errs() << InputGCDA << ": " << ec.message() << "\n"; - return 1; - } - GCOVBuffer GCDA_GB(GCDA_Buff.get()); - if (!GF.readGCDA(GCDA_GB)) { - errs() << "Invalid .gcda File!\n"; - return 1; + if (ec != errc::no_such_file_or_directory) { + errs() << InputGCDA << ": " << ec.message() << "\n"; + return 1; + } + // Clear the filename to make it clear we didn't read anything. + InputGCDA = "-"; + } else { + GCOVBuffer GCDA_GB(GCDA_Buff.get()); + if (!GF.readGCDA(GCDA_GB)) { + errs() << "Invalid .gcda File!\n"; + return 1; + } } if (DumpGCOV) -- cgit v1.2.3