diff options
author | Bob Wilson <bob.wilson@apple.com> | 2013-10-22 05:09:41 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2013-10-22 05:09:41 +0000 |
commit | e877eebfe9d716ed1101aecf958af473836e70e1 (patch) | |
tree | df2f081e28c655b896b933c73425b52e797c26e5 /lib | |
parent | 78fe4d62fb12fd3d77cac4d26ec1ab2010aace12 (diff) | |
download | external_llvm-e877eebfe9d716ed1101aecf958af473836e70e1.zip external_llvm-e877eebfe9d716ed1101aecf958af473836e70e1.tar.gz external_llvm-e877eebfe9d716ed1101aecf958af473836e70e1.tar.bz2 |
Change llvm-cov output formatting to be more similar to gcov.
- Replaced tabs with proper padding
- print() takes two arguments, which are the GCNO and GCDA filenames
- Files are listed at the top of output, appended by line 0
- Stripped strings of trailing \0s
- Removed last two lines of whitespace in output
Patch by Yuchen Wu!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IR/GCOV.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index b8907d0..36c5390 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -15,6 +15,7 @@ #include "llvm/Support/GCOV.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Format.h" #include "llvm/Support/MemoryObject.h" #include "llvm/Support/system_error.h" using namespace llvm; @@ -243,7 +244,7 @@ void FileInfo::addLineCount(StringRef Filename, uint32_t Line, uint32_t Count) { return; } StringRef AllLines = Buff.take()->getBuffer(); - LineCounts L(AllLines.count('\n')+2); + LineCounts L(AllLines.count('\n')); L[Line-1] = Count; LineInfo[Filename] = L; return; @@ -253,11 +254,13 @@ void FileInfo::addLineCount(StringRef Filename, uint32_t Line, uint32_t Count) { } /// print - Print source files with collected line count information. -void FileInfo::print() { +void FileInfo::print(StringRef gcnoFile, StringRef gcdaFile) { for (StringMap<LineCounts>::iterator I = LineInfo.begin(), E = LineInfo.end(); I != E; ++I) { StringRef Filename = I->first(); - outs() << Filename << "\n"; + outs() << " -: 0:Source:" << Filename << "\n"; + outs() << " -: 0:Graph:" << gcnoFile << "\n"; + outs() << " -: 0:Data:" << gcdaFile << "\n"; LineCounts &L = LineInfo[Filename]; OwningPtr<MemoryBuffer> Buff; if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) { @@ -267,16 +270,15 @@ void FileInfo::print() { StringRef AllLines = Buff.take()->getBuffer(); for (unsigned i = 0, e = L.size(); i != e; ++i) { if (L[i]) - outs() << L[i] << ":\t"; + outs() << format("%9lu:", L[i]); else - outs() << " :\t"; + outs() << " -:"; std::pair<StringRef, StringRef> P = AllLines.split('\n'); if (AllLines != P.first) - outs() << P.first; + outs() << format("%5u:", i+1) << P.first; outs() << "\n"; AllLines = P.second; } } } - |