summaryrefslogtreecommitdiff
path: root/lib/IR/GCOV.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/GCOV.cpp')
-rw-r--r--lib/IR/GCOV.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp
index c7a1102d10..fb7370020a 100644
--- a/lib/IR/GCOV.cpp
+++ b/lib/IR/GCOV.cpp
@@ -358,7 +358,8 @@ void GCOVBlock::dump() const {
// FileInfo implementation.
/// print - Print source files with collected line count information.
-void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const {
+void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile,
+ const GCOVOptions &Options) const {
for (StringMap<LineData>::const_iterator I = LineInfo.begin(),
E = LineInfo.end(); I != E; ++I) {
StringRef Filename = I->first();
@@ -385,13 +386,21 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const {
for (uint32_t i = 0; !AllLines.empty(); ++i) {
LineData::const_iterator BlocksIt = Line.find(i);
- // Add up the block counts to form line counts.
if (BlocksIt != Line.end()) {
+ // Add up the block counts to form line counts.
const BlockVector &Blocks = BlocksIt->second;
uint64_t LineCount = 0;
for (BlockVector::const_iterator I = Blocks.begin(), E = Blocks.end();
I != E; ++I) {
- LineCount += (*I)->getCount();
+ const GCOVBlock *Block = *I;
+ if (Options.AllBlocks) {
+ // Only take the highest block count for that line.
+ uint64_t BlockCount = Block->getCount();
+ LineCount = LineCount > BlockCount ? LineCount : BlockCount;
+ } else {
+ // Sum up all of the block counts.
+ LineCount += Block->getCount();
+ }
}
if (LineCount == 0)
OS << " #####:";
@@ -403,6 +412,24 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) const {
std::pair<StringRef, StringRef> P = AllLines.split('\n');
OS << format("%5u:", i+1) << P.first << "\n";
AllLines = P.second;
+
+ if (Options.AllBlocks && BlocksIt != Line.end()) {
+ // Output the counts for each block at the last line of the block.
+ uint32_t BlockNo = 0;
+ const BlockVector &Blocks = BlocksIt->second;
+ for (BlockVector::const_iterator I = Blocks.begin(), E = Blocks.end();
+ I != E; ++I) {
+ const GCOVBlock *Block = *I;
+ if (Block->getLastLine() != i+1)
+ continue;
+
+ if (Block->getCount() == 0)
+ OS << " $$$$$:";
+ else
+ OS << format("%9lu:", Block->getCount());
+ OS << format("%5u-block %u\n", i+1, BlockNo++);
+ }
+ }
}
}
}