llvm-cov: Disentangle the coverage data logic from the display (NFC)

This splits the logic for actually looking up coverage information
from the logic that displays it. These were tangled rather thoroughly
so this change is a bit large, but it mostly consists of moving things
around. The coverage lookup logic itself now lives in the library,
rather than being spread between the library and the tool.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Bogner
2014-09-20 15:31:56 +00:00
parent 73edcffc8f
commit 9eb38163a5
14 changed files with 542 additions and 479 deletions

View File

@@ -15,7 +15,6 @@
#define LLVM_COV_SOURCECOVERAGEVIEW_H
#include "CoverageViewOptions.h"
#include "SourceCoverageDataManager.h"
#include "llvm/ProfileData/CoverageMapping.h"
#include "llvm/Support/MemoryBuffer.h"
#include <vector>
@@ -105,14 +104,14 @@ private:
const MemoryBuffer &File;
const CoverageViewOptions &Options;
std::unique_ptr<SourceCoverageDataManager> RegionManager;
coverage::CoverageData CoverageInfo;
std::vector<ExpansionView> ExpansionSubViews;
std::vector<InstantiationView> InstantiationSubViews;
/// \brief Render a source line with highlighting.
void renderLine(raw_ostream &OS, StringRef Line, int64_t LineNumber,
const CoverageSegment *WrappedSegment,
ArrayRef<const CoverageSegment *> Segments,
const coverage::CoverageSegment *WrappedSegment,
ArrayRef<const coverage::CoverageSegment *> Segments,
unsigned ExpansionCol);
void renderIndent(raw_ostream &OS, unsigned Level);
@@ -126,16 +125,18 @@ private:
void renderLineNumberColumn(raw_ostream &OS, unsigned LineNo);
/// \brief Render all the region's execution counts on a line.
void renderRegionMarkers(raw_ostream &OS,
ArrayRef<const CoverageSegment *> Segments);
void
renderRegionMarkers(raw_ostream &OS,
ArrayRef<const coverage::CoverageSegment *> Segments);
static const unsigned LineCoverageColumnWidth = 7;
static const unsigned LineNumberColumnWidth = 5;
public:
SourceCoverageView(const MemoryBuffer &File,
const CoverageViewOptions &Options)
: File(File), Options(Options) {}
const CoverageViewOptions &Options,
coverage::CoverageData &&CoverageInfo)
: File(File), Options(Options), CoverageInfo(std::move(CoverageInfo)) {}
const CoverageViewOptions &getOptions() const { return Options; }
@@ -154,12 +155,6 @@ public:
/// \brief Print the code coverage information for a specific
/// portion of a source file to the output stream.
void render(raw_ostream &OS, bool WholeFile, unsigned IndentLevel = 0);
/// \brief Load the coverage information required for rendering
/// from the mapping regions in the data manager.
void load(std::unique_ptr<SourceCoverageDataManager> Data) {
RegionManager = std::move(Data);
}
};
} // namespace llvm