llvm.org GIT mirror llvm / d8acf00
llvm-cov: Added command-line option to change dir. This will allow for much easier testing when the input files are in a different folder from the test script. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194034 91177308-0d34-0410-b5e6-96231b3b80d8 Yuchen Wu 6 years ago
2 changed file(s) with 19 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
265265 for (StringMap::iterator I = LineInfo.begin(), E = LineInfo.end();
266266 I != E; ++I) {
267267 StringRef Filename = I->first();
268 OwningPtr Buff;
269 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
270 errs() << Filename << ": " << ec.message() << "\n";
271 return;
272 }
273 StringRef AllLines = Buff.take()->getBuffer();
274
268275 OS << " -: 0:Source:" << Filename << "\n";
269276 OS << " -: 0:Graph:" << gcnoFile << "\n";
270277 OS << " -: 0:Data:" << gcdaFile << "\n";
271278 OS << " -: 0:Runs:" << RunCount << "\n";
272279 OS << " -: 0:Programs:" << ProgramCount << "\n";
280
273281 LineCounts &L = LineInfo[Filename];
274 OwningPtr Buff;
275 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
276 errs() << Filename << ": " << ec.message() << "\n";
277 return;
278 }
279 StringRef AllLines = Buff.take()->getBuffer();
280282 uint32_t i = 0;
281283 while (!AllLines.empty()) {
282284 if (L.find(i) != L.end()) {
1919 #include "llvm/Support/raw_ostream.h"
2020 #include "llvm/Support/Signals.h"
2121 #include "llvm/Support/system_error.h"
22 #include
2223 using namespace llvm;
2324
2425 static cl::opt
3334 static cl::opt
3435 OutputFile("o", cl::desc(""), cl::init("-"));
3536
37 static cl::opt
38 WorkingDir("C", cl::desc("change path of working directory"),
39 cl::init(""));
3640
3741 //===----------------------------------------------------------------------===//
3842 int main(int argc, char **argv) {
4246 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
4347
4448 cl::ParseCommandLineOptions(argc, argv, "llvm coverage tool\n");
49
50 if (!WorkingDir.empty()) {
51 if (chdir(WorkingDir.c_str()) == -1) {
52 errs() << "Cannot change to directory: " << WorkingDir << ".\n";
53 return 1;
54 }
55 }
4556
4657 std::string ErrorInfo;
4758 raw_fd_ostream OS(OutputFile.c_str(), ErrorInfo);
7687 }
7788 }
7889
79
8090 if (DumpGCOV)
8191 GF.dump();
8292