[llvm] r193148 - Change llvm-cov output formatting to be more similar to gcov.
Bob Wilson
bob.wilson at apple.com
Mon Oct 21 22:09:42 PDT 2013
Author: bwilson
Date: Tue Oct 22 00:09:41 2013
New Revision: 193148
URL: http://llvm.org/viewvc/llvm-project?rev=193148&view=rev
Log:
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!
Modified:
llvm/trunk/include/llvm/Support/GCOV.h
llvm/trunk/lib/IR/GCOV.cpp
llvm/trunk/tools/llvm-cov/llvm-cov.cpp
Modified: llvm/trunk/include/llvm/Support/GCOV.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GCOV.h?rev=193148&r1=193147&r2=193148&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/GCOV.h (original)
+++ llvm/trunk/include/llvm/Support/GCOV.h Tue Oct 22 00:09:41 2013
@@ -145,7 +145,7 @@ public:
uint32_t Len = readInt() * 4;
StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+Len);
Cursor += Len;
- return Str;
+ return Str.split('\0').first;
}
uint64_t getCursor() const { return Cursor; }
@@ -216,7 +216,7 @@ typedef SmallVector<uint32_t, 16> LineCo
class FileInfo {
public:
void addLineCount(StringRef Filename, uint32_t Line, uint32_t Count);
- void print();
+ void print(StringRef gcnoFile, StringRef gcdaFile);
private:
StringMap<LineCounts> LineInfo;
};
Modified: llvm/trunk/lib/IR/GCOV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/GCOV.cpp?rev=193148&r1=193147&r2=193148&view=diff
==============================================================================
--- llvm/trunk/lib/IR/GCOV.cpp (original)
+++ llvm/trunk/lib/IR/GCOV.cpp Tue Oct 22 00:09:41 2013
@@ -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 Fi
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 Fi
}
/// 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;
}
}
}
-
Modified: llvm/trunk/tools/llvm-cov/llvm-cov.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/llvm-cov.cpp?rev=193148&r1=193147&r2=193148&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/llvm-cov.cpp (original)
+++ llvm/trunk/tools/llvm-cov/llvm-cov.cpp Tue Oct 22 00:09:41 2013
@@ -74,6 +74,6 @@ int main(int argc, char **argv) {
FileInfo FI;
GF.collectLineCounts(FI);
- FI.print();
+ FI.print(InputGCNO, InputGCDA);
return 0;
}
More information about the llvm-commits
mailing list