mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
InstrProf: Make CoverageMapping testable and add a basic unit test
Make CoverageMapping easier to create, so that we can write targeted unit tests for its internals, and add a some infrastructure to write these tests. Finally, add a simple unit test for basic functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229709 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -28,7 +28,7 @@ namespace llvm {
|
||||
class IndexedInstrProfReader;
|
||||
namespace coverage {
|
||||
|
||||
class ObjectFileCoverageMappingReader;
|
||||
class CoverageMappingReader;
|
||||
|
||||
class CoverageMapping;
|
||||
struct CounterExpressions;
|
||||
@ -333,10 +333,22 @@ struct CoverageSegment {
|
||||
CoverageSegment(unsigned Line, unsigned Col, bool IsRegionEntry)
|
||||
: Line(Line), Col(Col), Count(0), HasCount(false),
|
||||
IsRegionEntry(IsRegionEntry) {}
|
||||
|
||||
CoverageSegment(unsigned Line, unsigned Col, uint64_t Count,
|
||||
bool IsRegionEntry)
|
||||
: Line(Line), Col(Col), Count(Count), HasCount(true),
|
||||
IsRegionEntry(IsRegionEntry) {}
|
||||
|
||||
friend bool operator==(const CoverageSegment &L, const CoverageSegment &R) {
|
||||
return std::tie(L.Line, L.Col, L.Count, L.HasCount, L.IsRegionEntry) ==
|
||||
std::tie(R.Line, R.Col, R.Count, R.HasCount, R.IsRegionEntry);
|
||||
}
|
||||
|
||||
void setCount(uint64_t NewCount) {
|
||||
Count = NewCount;
|
||||
HasCount = true;
|
||||
}
|
||||
|
||||
void addCount(uint64_t NewCount) { setCount(Count + NewCount); }
|
||||
};
|
||||
|
||||
@ -384,7 +396,7 @@ class CoverageMapping {
|
||||
public:
|
||||
/// \brief Load the coverage mapping using the given readers.
|
||||
static ErrorOr<std::unique_ptr<CoverageMapping>>
|
||||
load(ObjectFileCoverageMappingReader &CoverageReader,
|
||||
load(CoverageMappingReader &CoverageReader,
|
||||
IndexedInstrProfReader &ProfileReader);
|
||||
|
||||
/// \brief Load the coverage mapping from the given files.
|
||||
|
Reference in New Issue
Block a user