Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 1 | //===- CodeCoverage.cpp - Coverage tool based on profiling instrumentation-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // The 'CodeCoverageTool' class implements a command line tool to analyze and |
| 11 | // report coverage information using the profiling instrumentation and code |
| 12 | // coverage mapping. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 16 | #include "CoverageFilters.h" |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 17 | #include "CoverageReport.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 18 | #include "CoverageViewOptions.h" |
Easwaran Raman | dc70712 | 2016-04-29 18:53:05 +0000 | [diff] [blame] | 19 | #include "RenderingSupport.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 20 | #include "SourceCoverageView.h" |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallString.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/StringRef.h" |
Justin Bogner | 4379535 | 2015-03-11 02:30:51 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/Triple.h" |
Easwaran Raman | dc70712 | 2016-04-29 18:53:05 +0000 | [diff] [blame] | 24 | #include "llvm/ProfileData/Coverage/CoverageMapping.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 25 | #include "llvm/ProfileData/InstrProfReader.h" |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 26 | #include "llvm/Support/CommandLine.h" |
| 27 | #include "llvm/Support/FileSystem.h" |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 28 | #include "llvm/Support/Format.h" |
| 29 | #include "llvm/Support/Path.h" |
Justin Bogner | cfb53e4 | 2015-03-19 00:02:23 +0000 | [diff] [blame] | 30 | #include "llvm/Support/Process.h" |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 31 | #include "llvm/Support/ThreadPool.h" |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 32 | #include <functional> |
Justin Bogner | e53be06 | 2014-09-09 05:32:18 +0000 | [diff] [blame] | 33 | #include <system_error> |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 34 | |
| 35 | using namespace llvm; |
| 36 | using namespace coverage; |
| 37 | |
| 38 | namespace { |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 39 | /// \brief The implementation of the coverage tool. |
| 40 | class CodeCoverageTool { |
| 41 | public: |
| 42 | enum Command { |
| 43 | /// \brief The show command. |
| 44 | Show, |
| 45 | /// \brief The report command. |
| 46 | Report |
| 47 | }; |
| 48 | |
| 49 | /// \brief Print the error message to the error output stream. |
| 50 | void error(const Twine &Message, StringRef Whence = ""); |
| 51 | |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 52 | /// \brief Record (but do not print) an error message in a thread-safe way. |
| 53 | void deferError(const Twine &Message, StringRef Whence = ""); |
| 54 | |
| 55 | /// \brief Record (but do not print) a warning message in a thread-safe way. |
| 56 | void deferWarning(const Twine &Message, StringRef Whence = ""); |
| 57 | |
| 58 | /// \brief Print (and then clear) all deferred error and warning messages. |
| 59 | void consumeDeferredMessages(); |
| 60 | |
Vedant Kumar | cef440f | 2016-06-28 16:12:18 +0000 | [diff] [blame] | 61 | /// \brief Append a reference to a private copy of \p Path into SourceFiles. |
| 62 | void addCollectedPath(const std::string &Path); |
| 63 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 64 | /// \brief Return a memory buffer for the given source file. |
| 65 | ErrorOr<const MemoryBuffer &> getSourceFile(StringRef SourceFile); |
| 66 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 67 | /// \brief Create source views for the expansions of the view. |
| 68 | void attachExpansionSubViews(SourceCoverageView &View, |
| 69 | ArrayRef<ExpansionRecord> Expansions, |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 70 | const CoverageMapping &Coverage); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 71 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 72 | /// \brief Create the source view of a particular function. |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 73 | std::unique_ptr<SourceCoverageView> |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 74 | createFunctionView(const FunctionRecord &Function, |
| 75 | const CoverageMapping &Coverage); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 76 | |
| 77 | /// \brief Create the main source view of a particular source file. |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 78 | std::unique_ptr<SourceCoverageView> |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 79 | createSourceFileView(StringRef SourceFile, const CoverageMapping &Coverage); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 80 | |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 81 | /// \brief Load the coverage mapping data. Return nullptr if an error occured. |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 82 | std::unique_ptr<CoverageMapping> load(); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 83 | |
| 84 | int run(Command Cmd, int argc, const char **argv); |
| 85 | |
Benjamin Kramer | c321e53 | 2016-06-08 19:09:22 +0000 | [diff] [blame] | 86 | typedef llvm::function_ref<int(int, const char **)> CommandLineParserType; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 87 | |
| 88 | int show(int argc, const char **argv, |
| 89 | CommandLineParserType commandLineParser); |
| 90 | |
| 91 | int report(int argc, const char **argv, |
| 92 | CommandLineParserType commandLineParser); |
| 93 | |
Justin Bogner | f6c5055 | 2014-10-30 20:51:24 +0000 | [diff] [blame] | 94 | std::string ObjectFilename; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 95 | CoverageViewOptions ViewOpts; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 96 | std::string PGOFilename; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 97 | CoverageFiltersMatchAll Filters; |
Vedant Kumar | cef440f | 2016-06-28 16:12:18 +0000 | [diff] [blame] | 98 | std::vector<StringRef> SourceFiles; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 99 | bool CompareFilenamesOnly; |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 100 | StringMap<std::string> RemappedFilenames; |
Frederic Riss | ebc162a | 2015-06-22 21:33:24 +0000 | [diff] [blame] | 101 | std::string CoverageArch; |
Vedant Kumar | cef440f | 2016-06-28 16:12:18 +0000 | [diff] [blame] | 102 | |
| 103 | private: |
| 104 | std::vector<std::string> CollectedPaths; |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 105 | |
| 106 | std::mutex DeferredMessagesLock; |
| 107 | std::vector<std::string> DeferredMessages; |
| 108 | |
| 109 | std::mutex LoadedSourceFilesLock; |
| 110 | std::vector<std::pair<std::string, std::unique_ptr<MemoryBuffer>>> |
| 111 | LoadedSourceFiles; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 112 | }; |
| 113 | } |
| 114 | |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 115 | static std::string getErrorString(const Twine &Message, StringRef Whence, |
| 116 | bool Warning) { |
| 117 | std::string Str = (Warning ? "warning" : "error"); |
| 118 | Str += ": "; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 119 | if (!Whence.empty()) |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 120 | Str += Whence; |
| 121 | Str += Message.str() + "\n"; |
| 122 | return Str; |
| 123 | } |
| 124 | |
| 125 | void CodeCoverageTool::error(const Twine &Message, StringRef Whence) { |
| 126 | errs() << getErrorString(Message, Whence, false); |
| 127 | } |
| 128 | |
| 129 | void CodeCoverageTool::deferError(const Twine &Message, StringRef Whence) { |
| 130 | std::unique_lock<std::mutex> Guard{DeferredMessagesLock}; |
| 131 | DeferredMessages.emplace_back(getErrorString(Message, Whence, false)); |
| 132 | } |
| 133 | |
| 134 | void CodeCoverageTool::deferWarning(const Twine &Message, StringRef Whence) { |
| 135 | std::unique_lock<std::mutex> Guard{DeferredMessagesLock}; |
| 136 | DeferredMessages.emplace_back(getErrorString(Message, Whence, true)); |
| 137 | } |
| 138 | |
| 139 | void CodeCoverageTool::consumeDeferredMessages() { |
| 140 | std::unique_lock<std::mutex> Guard{DeferredMessagesLock}; |
| 141 | for (const std::string &Message : DeferredMessages) |
| 142 | ViewOpts.colored_ostream(errs(), raw_ostream::RED) << Message; |
| 143 | DeferredMessages.clear(); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Vedant Kumar | cef440f | 2016-06-28 16:12:18 +0000 | [diff] [blame] | 146 | void CodeCoverageTool::addCollectedPath(const std::string &Path) { |
| 147 | CollectedPaths.push_back(Path); |
| 148 | SourceFiles.emplace_back(CollectedPaths.back()); |
| 149 | } |
| 150 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 151 | ErrorOr<const MemoryBuffer &> |
| 152 | CodeCoverageTool::getSourceFile(StringRef SourceFile) { |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 153 | // If we've remapped filenames, look up the real location for this file. |
| 154 | if (!RemappedFilenames.empty()) { |
| 155 | auto Loc = RemappedFilenames.find(SourceFile); |
| 156 | if (Loc != RemappedFilenames.end()) |
| 157 | SourceFile = Loc->second; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 158 | } |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 159 | for (const auto &Files : LoadedSourceFiles) |
| 160 | if (sys::fs::equivalent(SourceFile, Files.first)) |
| 161 | return *Files.second; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 162 | auto Buffer = MemoryBuffer::getFile(SourceFile); |
| 163 | if (auto EC = Buffer.getError()) { |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 164 | deferError(EC.message(), SourceFile); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 165 | return EC; |
| 166 | } |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 167 | std::unique_lock<std::mutex> Guard{LoadedSourceFilesLock}; |
Benjamin Kramer | f5e2fc4 | 2015-05-29 19:43:39 +0000 | [diff] [blame] | 168 | LoadedSourceFiles.emplace_back(SourceFile, std::move(Buffer.get())); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 169 | return *LoadedSourceFiles.back().second; |
| 170 | } |
| 171 | |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 172 | void CodeCoverageTool::attachExpansionSubViews( |
| 173 | SourceCoverageView &View, ArrayRef<ExpansionRecord> Expansions, |
| 174 | const CoverageMapping &Coverage) { |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 175 | if (!ViewOpts.ShowExpandedRegions) |
| 176 | return; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 177 | for (const auto &Expansion : Expansions) { |
| 178 | auto ExpansionCoverage = Coverage.getCoverageForExpansion(Expansion); |
| 179 | if (ExpansionCoverage.empty()) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 180 | continue; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 181 | auto SourceBuffer = getSourceFile(ExpansionCoverage.getFilename()); |
| 182 | if (!SourceBuffer) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 183 | continue; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 184 | |
| 185 | auto SubViewExpansions = ExpansionCoverage.getExpansions(); |
Vedant Kumar | f9151b9 | 2016-06-25 02:58:30 +0000 | [diff] [blame] | 186 | auto SubView = |
| 187 | SourceCoverageView::create(Expansion.Function.Name, SourceBuffer.get(), |
| 188 | ViewOpts, std::move(ExpansionCoverage)); |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 189 | attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); |
| 190 | View.addExpansion(Expansion.Region, std::move(SubView)); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 194 | std::unique_ptr<SourceCoverageView> |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 195 | CodeCoverageTool::createFunctionView(const FunctionRecord &Function, |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 196 | const CoverageMapping &Coverage) { |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 197 | auto FunctionCoverage = Coverage.getCoverageForFunction(Function); |
| 198 | if (FunctionCoverage.empty()) |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 199 | return nullptr; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 200 | auto SourceBuffer = getSourceFile(FunctionCoverage.getFilename()); |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 201 | if (!SourceBuffer) |
| 202 | return nullptr; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 203 | |
| 204 | auto Expansions = FunctionCoverage.getExpansions(); |
Vedant Kumar | f9151b9 | 2016-06-25 02:58:30 +0000 | [diff] [blame] | 205 | auto View = SourceCoverageView::create(Function.Name, SourceBuffer.get(), |
| 206 | ViewOpts, std::move(FunctionCoverage)); |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 207 | attachExpansionSubViews(*View, Expansions, Coverage); |
| 208 | |
| 209 | return View; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 210 | } |
| 211 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 212 | std::unique_ptr<SourceCoverageView> |
| 213 | CodeCoverageTool::createSourceFileView(StringRef SourceFile, |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 214 | const CoverageMapping &Coverage) { |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 215 | auto SourceBuffer = getSourceFile(SourceFile); |
| 216 | if (!SourceBuffer) |
| 217 | return nullptr; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 218 | auto FileCoverage = Coverage.getCoverageForFile(SourceFile); |
| 219 | if (FileCoverage.empty()) |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 220 | return nullptr; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 221 | |
| 222 | auto Expansions = FileCoverage.getExpansions(); |
Vedant Kumar | f9151b9 | 2016-06-25 02:58:30 +0000 | [diff] [blame] | 223 | auto View = SourceCoverageView::create(SourceFile, SourceBuffer.get(), |
| 224 | ViewOpts, std::move(FileCoverage)); |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 225 | attachExpansionSubViews(*View, Expansions, Coverage); |
| 226 | |
Vedant Kumar | f681e2e | 2016-07-15 01:19:33 +0000 | [diff] [blame] | 227 | for (const auto *Function : Coverage.getInstantiations(SourceFile)) { |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 228 | auto SubViewCoverage = Coverage.getCoverageForFunction(*Function); |
| 229 | auto SubViewExpansions = SubViewCoverage.getExpansions(); |
Vedant Kumar | f9151b9 | 2016-06-25 02:58:30 +0000 | [diff] [blame] | 230 | auto SubView = |
| 231 | SourceCoverageView::create(Function->Name, SourceBuffer.get(), ViewOpts, |
| 232 | std::move(SubViewCoverage)); |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 233 | attachExpansionSubViews(*SubView, SubViewExpansions, Coverage); |
| 234 | |
| 235 | if (SubView) { |
Justin Bogner | 5e1400a | 2014-09-17 05:33:20 +0000 | [diff] [blame] | 236 | unsigned FileID = Function->CountedRegions.front().FileID; |
| 237 | unsigned Line = 0; |
| 238 | for (const auto &CR : Function->CountedRegions) |
| 239 | if (CR.FileID == FileID) |
| 240 | Line = std::max(CR.LineEnd, Line); |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 241 | View->addInstantiation(Function->Name, Line, std::move(SubView)); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 242 | } |
| 243 | } |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 244 | return View; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Justin Bogner | 65337d1 | 2015-05-04 04:09:38 +0000 | [diff] [blame] | 247 | static bool modifiedTimeGT(StringRef LHS, StringRef RHS) { |
| 248 | sys::fs::file_status Status; |
| 249 | if (sys::fs::status(LHS, Status)) |
| 250 | return false; |
| 251 | auto LHSTime = Status.getLastModificationTime(); |
| 252 | if (sys::fs::status(RHS, Status)) |
| 253 | return false; |
| 254 | auto RHSTime = Status.getLastModificationTime(); |
| 255 | return LHSTime > RHSTime; |
| 256 | } |
| 257 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 258 | std::unique_ptr<CoverageMapping> CodeCoverageTool::load() { |
Justin Bogner | 65337d1 | 2015-05-04 04:09:38 +0000 | [diff] [blame] | 259 | if (modifiedTimeGT(ObjectFilename, PGOFilename)) |
| 260 | errs() << "warning: profile data may be out of date - object is newer\n"; |
Justin Bogner | 4379535 | 2015-03-11 02:30:51 +0000 | [diff] [blame] | 261 | auto CoverageOrErr = CoverageMapping::load(ObjectFilename, PGOFilename, |
| 262 | CoverageArch); |
Vedant Kumar | 9152fd1 | 2016-05-19 03:54:45 +0000 | [diff] [blame] | 263 | if (Error E = CoverageOrErr.takeError()) { |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 264 | colored_ostream(errs(), raw_ostream::RED) |
Vedant Kumar | 9152fd1 | 2016-05-19 03:54:45 +0000 | [diff] [blame] | 265 | << "error: Failed to load coverage: " << toString(std::move(E)) << "\n"; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 266 | return nullptr; |
| 267 | } |
| 268 | auto Coverage = std::move(CoverageOrErr.get()); |
| 269 | unsigned Mismatched = Coverage->getMismatchedCount(); |
| 270 | if (Mismatched) { |
| 271 | colored_ostream(errs(), raw_ostream::RED) |
| 272 | << "warning: " << Mismatched << " functions have mismatched data. "; |
| 273 | errs() << "\n"; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 274 | } |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 275 | |
| 276 | if (CompareFilenamesOnly) { |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 277 | auto CoveredFiles = Coverage.get()->getUniqueSourceFiles(); |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 278 | for (auto &SF : SourceFiles) { |
| 279 | StringRef SFBase = sys::path::filename(SF); |
| 280 | for (const auto &CF : CoveredFiles) |
| 281 | if (SFBase == sys::path::filename(CF)) { |
| 282 | RemappedFilenames[CF] = SF; |
| 283 | SF = CF; |
| 284 | break; |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 289 | return Coverage; |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) { |
Justin Bogner | f6c5055 | 2014-10-30 20:51:24 +0000 | [diff] [blame] | 293 | cl::opt<std::string, true> ObjectFilename( |
| 294 | cl::Positional, cl::Required, cl::location(this->ObjectFilename), |
| 295 | cl::desc("Covered executable or object file.")); |
| 296 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 297 | cl::list<std::string> InputSourceFiles( |
| 298 | cl::Positional, cl::desc("<Source files>"), cl::ZeroOrMore); |
| 299 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 300 | cl::opt<std::string, true> PGOFilename( |
| 301 | "instr-profile", cl::Required, cl::location(this->PGOFilename), |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 302 | cl::desc( |
| 303 | "File with the profile data obtained after an instrumented run")); |
| 304 | |
Justin Bogner | 4379535 | 2015-03-11 02:30:51 +0000 | [diff] [blame] | 305 | cl::opt<std::string> Arch( |
| 306 | "arch", cl::desc("architecture of the coverage mapping binary")); |
| 307 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 308 | cl::opt<bool> DebugDump("dump", cl::Optional, |
| 309 | cl::desc("Show internal debug dump")); |
| 310 | |
Vedant Kumar | 8d74cb2 | 2016-06-29 00:38:21 +0000 | [diff] [blame] | 311 | cl::opt<CoverageViewOptions::OutputFormat> Format( |
| 312 | "format", cl::desc("Output format for line-based coverage reports"), |
| 313 | cl::values(clEnumValN(CoverageViewOptions::OutputFormat::Text, "text", |
| 314 | "Text output"), |
Vedant Kumar | 4c01092 | 2016-07-06 21:44:05 +0000 | [diff] [blame] | 315 | clEnumValN(CoverageViewOptions::OutputFormat::HTML, "html", |
| 316 | "HTML output"), |
Vedant Kumar | 8d74cb2 | 2016-06-29 00:38:21 +0000 | [diff] [blame] | 317 | clEnumValEnd), |
| 318 | cl::init(CoverageViewOptions::OutputFormat::Text)); |
| 319 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 320 | cl::opt<bool> FilenameEquivalence( |
| 321 | "filename-equivalence", cl::Optional, |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 322 | cl::desc("Treat source files as equivalent to paths in the coverage data " |
| 323 | "when the file names match, even if the full paths do not")); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 324 | |
| 325 | cl::OptionCategory FilteringCategory("Function filtering options"); |
| 326 | |
| 327 | cl::list<std::string> NameFilters( |
| 328 | "name", cl::Optional, |
| 329 | cl::desc("Show code coverage only for functions with the given name"), |
| 330 | cl::ZeroOrMore, cl::cat(FilteringCategory)); |
| 331 | |
| 332 | cl::list<std::string> NameRegexFilters( |
| 333 | "name-regex", cl::Optional, |
| 334 | cl::desc("Show code coverage only for functions that match the given " |
| 335 | "regular expression"), |
| 336 | cl::ZeroOrMore, cl::cat(FilteringCategory)); |
| 337 | |
| 338 | cl::opt<double> RegionCoverageLtFilter( |
| 339 | "region-coverage-lt", cl::Optional, |
| 340 | cl::desc("Show code coverage only for functions with region coverage " |
| 341 | "less than the given threshold"), |
| 342 | cl::cat(FilteringCategory)); |
| 343 | |
| 344 | cl::opt<double> RegionCoverageGtFilter( |
| 345 | "region-coverage-gt", cl::Optional, |
| 346 | cl::desc("Show code coverage only for functions with region coverage " |
| 347 | "greater than the given threshold"), |
| 348 | cl::cat(FilteringCategory)); |
| 349 | |
| 350 | cl::opt<double> LineCoverageLtFilter( |
| 351 | "line-coverage-lt", cl::Optional, |
| 352 | cl::desc("Show code coverage only for functions with line coverage less " |
| 353 | "than the given threshold"), |
| 354 | cl::cat(FilteringCategory)); |
| 355 | |
| 356 | cl::opt<double> LineCoverageGtFilter( |
| 357 | "line-coverage-gt", cl::Optional, |
| 358 | cl::desc("Show code coverage only for functions with line coverage " |
| 359 | "greater than the given threshold"), |
| 360 | cl::cat(FilteringCategory)); |
| 361 | |
Justin Bogner | 9deb1d4 | 2015-03-19 04:45:16 +0000 | [diff] [blame] | 362 | cl::opt<cl::boolOrDefault> UseColor( |
| 363 | "use-color", cl::desc("Emit colored output (default=autodetect)"), |
| 364 | cl::init(cl::BOU_UNSET)); |
Justin Bogner | cfb53e4 | 2015-03-19 00:02:23 +0000 | [diff] [blame] | 365 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 366 | auto commandLineParser = [&, this](int argc, const char **argv) -> int { |
| 367 | cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n"); |
| 368 | ViewOpts.Debug = DebugDump; |
| 369 | CompareFilenamesOnly = FilenameEquivalence; |
| 370 | |
Vedant Kumar | 8d74cb2 | 2016-06-29 00:38:21 +0000 | [diff] [blame] | 371 | ViewOpts.Format = Format; |
| 372 | switch (ViewOpts.Format) { |
| 373 | case CoverageViewOptions::OutputFormat::Text: |
| 374 | ViewOpts.Colors = UseColor == cl::BOU_UNSET |
| 375 | ? sys::Process::StandardOutHasColors() |
| 376 | : UseColor == cl::BOU_TRUE; |
| 377 | break; |
Vedant Kumar | 4c01092 | 2016-07-06 21:44:05 +0000 | [diff] [blame] | 378 | case CoverageViewOptions::OutputFormat::HTML: |
| 379 | if (UseColor == cl::BOU_FALSE) |
| 380 | error("Color output cannot be disabled when generating html."); |
| 381 | ViewOpts.Colors = true; |
| 382 | break; |
Vedant Kumar | 8d74cb2 | 2016-06-29 00:38:21 +0000 | [diff] [blame] | 383 | } |
Justin Bogner | cfb53e4 | 2015-03-19 00:02:23 +0000 | [diff] [blame] | 384 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 385 | // Create the function filters |
| 386 | if (!NameFilters.empty() || !NameRegexFilters.empty()) { |
| 387 | auto NameFilterer = new CoverageFilters; |
| 388 | for (const auto &Name : NameFilters) |
| 389 | NameFilterer->push_back(llvm::make_unique<NameCoverageFilter>(Name)); |
| 390 | for (const auto &Regex : NameRegexFilters) |
| 391 | NameFilterer->push_back( |
| 392 | llvm::make_unique<NameRegexCoverageFilter>(Regex)); |
| 393 | Filters.push_back(std::unique_ptr<CoverageFilter>(NameFilterer)); |
| 394 | } |
| 395 | if (RegionCoverageLtFilter.getNumOccurrences() || |
| 396 | RegionCoverageGtFilter.getNumOccurrences() || |
| 397 | LineCoverageLtFilter.getNumOccurrences() || |
| 398 | LineCoverageGtFilter.getNumOccurrences()) { |
| 399 | auto StatFilterer = new CoverageFilters; |
| 400 | if (RegionCoverageLtFilter.getNumOccurrences()) |
| 401 | StatFilterer->push_back(llvm::make_unique<RegionCoverageFilter>( |
| 402 | RegionCoverageFilter::LessThan, RegionCoverageLtFilter)); |
| 403 | if (RegionCoverageGtFilter.getNumOccurrences()) |
| 404 | StatFilterer->push_back(llvm::make_unique<RegionCoverageFilter>( |
| 405 | RegionCoverageFilter::GreaterThan, RegionCoverageGtFilter)); |
| 406 | if (LineCoverageLtFilter.getNumOccurrences()) |
| 407 | StatFilterer->push_back(llvm::make_unique<LineCoverageFilter>( |
| 408 | LineCoverageFilter::LessThan, LineCoverageLtFilter)); |
| 409 | if (LineCoverageGtFilter.getNumOccurrences()) |
| 410 | StatFilterer->push_back(llvm::make_unique<LineCoverageFilter>( |
| 411 | RegionCoverageFilter::GreaterThan, LineCoverageGtFilter)); |
| 412 | Filters.push_back(std::unique_ptr<CoverageFilter>(StatFilterer)); |
| 413 | } |
| 414 | |
Frederic Riss | ebc162a | 2015-06-22 21:33:24 +0000 | [diff] [blame] | 415 | if (!Arch.empty() && |
| 416 | Triple(Arch).getArch() == llvm::Triple::ArchType::UnknownArch) { |
| 417 | errs() << "error: Unknown architecture: " << Arch << "\n"; |
| 418 | return 1; |
Justin Bogner | 4379535 | 2015-03-11 02:30:51 +0000 | [diff] [blame] | 419 | } |
Frederic Riss | ebc162a | 2015-06-22 21:33:24 +0000 | [diff] [blame] | 420 | CoverageArch = Arch; |
Justin Bogner | 4379535 | 2015-03-11 02:30:51 +0000 | [diff] [blame] | 421 | |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 422 | for (const auto &File : InputSourceFiles) { |
| 423 | SmallString<128> Path(File); |
Justin Bogner | 0ef7a2a | 2015-02-14 02:05:05 +0000 | [diff] [blame] | 424 | if (!CompareFilenamesOnly) |
| 425 | if (std::error_code EC = sys::fs::make_absolute(Path)) { |
| 426 | errs() << "error: " << File << ": " << EC.message(); |
| 427 | return 1; |
| 428 | } |
Vedant Kumar | cef440f | 2016-06-28 16:12:18 +0000 | [diff] [blame] | 429 | addCollectedPath(Path.str()); |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 430 | } |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 431 | return 0; |
| 432 | }; |
| 433 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 434 | switch (Cmd) { |
| 435 | case Show: |
| 436 | return show(argc, argv, commandLineParser); |
| 437 | case Report: |
| 438 | return report(argc, argv, commandLineParser); |
| 439 | } |
| 440 | return 0; |
| 441 | } |
| 442 | |
| 443 | int CodeCoverageTool::show(int argc, const char **argv, |
| 444 | CommandLineParserType commandLineParser) { |
| 445 | |
| 446 | cl::OptionCategory ViewCategory("Viewing options"); |
| 447 | |
| 448 | cl::opt<bool> ShowLineExecutionCounts( |
| 449 | "show-line-counts", cl::Optional, |
| 450 | cl::desc("Show the execution counts for each line"), cl::init(true), |
| 451 | cl::cat(ViewCategory)); |
| 452 | |
| 453 | cl::opt<bool> ShowRegions( |
| 454 | "show-regions", cl::Optional, |
| 455 | cl::desc("Show the execution counts for each region"), |
| 456 | cl::cat(ViewCategory)); |
| 457 | |
| 458 | cl::opt<bool> ShowBestLineRegionsCounts( |
| 459 | "show-line-counts-or-regions", cl::Optional, |
| 460 | cl::desc("Show the execution counts for each line, or the execution " |
| 461 | "counts for each region on lines that have multiple regions"), |
| 462 | cl::cat(ViewCategory)); |
| 463 | |
| 464 | cl::opt<bool> ShowExpansions("show-expansions", cl::Optional, |
| 465 | cl::desc("Show expanded source regions"), |
| 466 | cl::cat(ViewCategory)); |
| 467 | |
| 468 | cl::opt<bool> ShowInstantiations("show-instantiations", cl::Optional, |
| 469 | cl::desc("Show function instantiations"), |
| 470 | cl::cat(ViewCategory)); |
| 471 | |
Vedant Kumar | 7937ef3 | 2016-06-28 02:09:39 +0000 | [diff] [blame] | 472 | cl::opt<std::string> ShowOutputDirectory( |
| 473 | "output-dir", cl::init(""), |
| 474 | cl::desc("Directory in which coverage information is written out")); |
| 475 | cl::alias ShowOutputDirectoryA("o", cl::desc("Alias for --output-dir"), |
| 476 | cl::aliasopt(ShowOutputDirectory)); |
| 477 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 478 | auto Err = commandLineParser(argc, argv); |
| 479 | if (Err) |
| 480 | return Err; |
| 481 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 482 | ViewOpts.ShowLineNumbers = true; |
| 483 | ViewOpts.ShowLineStats = ShowLineExecutionCounts.getNumOccurrences() != 0 || |
| 484 | !ShowRegions || ShowBestLineRegionsCounts; |
| 485 | ViewOpts.ShowRegionMarkers = ShowRegions || ShowBestLineRegionsCounts; |
| 486 | ViewOpts.ShowLineStatsOrRegionMarkers = ShowBestLineRegionsCounts; |
| 487 | ViewOpts.ShowExpandedRegions = ShowExpansions; |
| 488 | ViewOpts.ShowFunctionInstantiations = ShowInstantiations; |
Vedant Kumar | 7937ef3 | 2016-06-28 02:09:39 +0000 | [diff] [blame] | 489 | ViewOpts.ShowOutputDirectory = ShowOutputDirectory; |
| 490 | |
Vedant Kumar | 64d8a02 | 2016-06-28 16:12:20 +0000 | [diff] [blame] | 491 | if (ViewOpts.hasOutputDirectory()) { |
Vedant Kumar | 7937ef3 | 2016-06-28 02:09:39 +0000 | [diff] [blame] | 492 | if (auto E = sys::fs::create_directories(ViewOpts.ShowOutputDirectory)) { |
| 493 | error("Could not create output directory!", E.message()); |
| 494 | return 1; |
| 495 | } |
| 496 | } |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 497 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 498 | auto Coverage = load(); |
| 499 | if (!Coverage) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 500 | return 1; |
| 501 | |
Vedant Kumar | 9cbad2c | 2016-06-28 16:12:24 +0000 | [diff] [blame] | 502 | auto Printer = CoveragePrinter::create(ViewOpts); |
| 503 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 504 | if (!Filters.empty()) { |
Vedant Kumar | 8d74cb2 | 2016-06-29 00:38:21 +0000 | [diff] [blame] | 505 | auto OSOrErr = Printer->createViewFile("functions", /*InToplevel=*/true); |
| 506 | if (Error E = OSOrErr.takeError()) { |
| 507 | error(toString(std::move(E))); |
| 508 | return 1; |
| 509 | } |
| 510 | auto OS = std::move(OSOrErr.get()); |
| 511 | |
| 512 | // Show functions. |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 513 | for (const auto &Function : Coverage->getCoveredFunctions()) { |
| 514 | if (!Filters.matches(Function)) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 515 | continue; |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 516 | |
| 517 | auto mainView = createFunctionView(Function, *Coverage); |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 518 | if (!mainView) { |
Vedant Kumar | 2c96e88 | 2016-06-24 02:33:01 +0000 | [diff] [blame] | 519 | ViewOpts.colored_ostream(errs(), raw_ostream::RED) |
| 520 | << "warning: Could not read coverage for '" << Function.Name << "'." |
| 521 | << "\n"; |
Justin Bogner | 5a6edad | 2014-09-19 19:07:17 +0000 | [diff] [blame] | 522 | continue; |
| 523 | } |
Vedant Kumar | 7937ef3 | 2016-06-28 02:09:39 +0000 | [diff] [blame] | 524 | |
Vedant Kumar | 7937ef3 | 2016-06-28 02:09:39 +0000 | [diff] [blame] | 525 | mainView->print(*OS.get(), /*WholeFile=*/false, /*ShowSourceName=*/true); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 526 | } |
Vedant Kumar | 8d74cb2 | 2016-06-29 00:38:21 +0000 | [diff] [blame] | 527 | |
| 528 | Printer->closeViewFile(std::move(OS)); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 529 | return 0; |
| 530 | } |
| 531 | |
| 532 | // Show files |
| 533 | bool ShowFilenames = SourceFiles.size() != 1; |
| 534 | |
Justin Bogner | 116c166 | 2014-09-19 08:13:12 +0000 | [diff] [blame] | 535 | if (SourceFiles.empty()) |
Vedant Kumar | 64d8a02 | 2016-06-28 16:12:20 +0000 | [diff] [blame] | 536 | // Get the source files from the function coverage mapping. |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 537 | for (StringRef Filename : Coverage->getUniqueSourceFiles()) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 538 | SourceFiles.push_back(Filename); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 539 | |
Vedant Kumar | 9cbad2c | 2016-06-28 16:12:24 +0000 | [diff] [blame] | 540 | // Create an index out of the source files. |
| 541 | if (ViewOpts.hasOutputDirectory()) { |
| 542 | if (Error E = Printer->createIndexFile(SourceFiles)) { |
| 543 | error(toString(std::move(E))); |
| 544 | return 1; |
| 545 | } |
| 546 | } |
| 547 | |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 548 | // In -output-dir mode, it's safe to use multiple threads to print files. |
| 549 | unsigned ThreadCount = 1; |
| 550 | if (ViewOpts.hasOutputDirectory()) |
| 551 | ThreadCount = std::thread::hardware_concurrency(); |
| 552 | ThreadPool Pool(ThreadCount); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 553 | |
Vedant Kumar | 84c452d | 2016-07-15 01:19:35 +0000 | [diff] [blame^] | 554 | for (StringRef SourceFile : SourceFiles) { |
| 555 | Pool.async([this, SourceFile, &Coverage, &Printer, ShowFilenames] { |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 556 | auto View = createSourceFileView(SourceFile, *Coverage); |
| 557 | if (!View) { |
| 558 | deferWarning("The file '" + SourceFile.str() + "' isn't covered."); |
| 559 | return; |
| 560 | } |
| 561 | |
| 562 | auto OSOrErr = Printer->createViewFile(SourceFile, /*InToplevel=*/false); |
| 563 | if (Error E = OSOrErr.takeError()) { |
| 564 | deferError(toString(std::move(E))); |
| 565 | return; |
| 566 | } |
| 567 | auto OS = std::move(OSOrErr.get()); |
| 568 | |
| 569 | View->print(*OS.get(), /*Wholefile=*/true, |
| 570 | /*ShowSourceName=*/ShowFilenames); |
| 571 | Printer->closeViewFile(std::move(OS)); |
| 572 | }); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 573 | } |
| 574 | |
Vedant Kumar | 86b2ac63 | 2016-07-13 21:38:36 +0000 | [diff] [blame] | 575 | Pool.wait(); |
| 576 | |
| 577 | consumeDeferredMessages(); |
| 578 | |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | int CodeCoverageTool::report(int argc, const char **argv, |
| 583 | CommandLineParserType commandLineParser) { |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 584 | auto Err = commandLineParser(argc, argv); |
| 585 | if (Err) |
| 586 | return Err; |
| 587 | |
Vedant Kumar | 4c01092 | 2016-07-06 21:44:05 +0000 | [diff] [blame] | 588 | if (ViewOpts.Format == CoverageViewOptions::OutputFormat::HTML) |
| 589 | error("HTML output for summary reports is not yet supported."); |
| 590 | |
Justin Bogner | 953e240 | 2014-09-20 15:31:56 +0000 | [diff] [blame] | 591 | auto Coverage = load(); |
| 592 | if (!Coverage) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 593 | return 1; |
| 594 | |
Justin Bogner | f91bc6c | 2015-02-14 02:01:24 +0000 | [diff] [blame] | 595 | CoverageReport Report(ViewOpts, std::move(Coverage)); |
Justin Bogner | 0ef7a2a | 2015-02-14 02:05:05 +0000 | [diff] [blame] | 596 | if (SourceFiles.empty()) |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 597 | Report.renderFileReports(llvm::outs()); |
Justin Bogner | 0ef7a2a | 2015-02-14 02:05:05 +0000 | [diff] [blame] | 598 | else |
| 599 | Report.renderFunctionReports(SourceFiles, llvm::outs()); |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 600 | return 0; |
| 601 | } |
| 602 | |
Justin Bogner | d249a3b | 2014-10-30 20:57:49 +0000 | [diff] [blame] | 603 | int showMain(int argc, const char *argv[]) { |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 604 | CodeCoverageTool Tool; |
| 605 | return Tool.run(CodeCoverageTool::Show, argc, argv); |
| 606 | } |
| 607 | |
Justin Bogner | d249a3b | 2014-10-30 20:57:49 +0000 | [diff] [blame] | 608 | int reportMain(int argc, const char *argv[]) { |
Alex Lorenz | e82d89c | 2014-08-22 22:56:03 +0000 | [diff] [blame] | 609 | CodeCoverageTool Tool; |
| 610 | return Tool.run(CodeCoverageTool::Report, argc, argv); |
| 611 | } |