mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
f8361e4518
This commit expands llvm-cov's functionality by adding support for a new code coverage tool that uses LLVM's coverage mapping format and clang's instrumentation based profiling. The gcov compatible tool can be invoked by supplying the 'gcov' command as the first argument, or by modifying the tool's name to end with 'gcov'. Differential Revision: http://reviews.llvm.org/D4445 llvm-svn: 216300
132 lines
4.3 KiB
C++
132 lines
4.3 KiB
C++
//===- CoverageSummaryInfo.h - Coverage summary for function/file ---------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// These structures are used to represent code coverage metrics
|
|
// for functions/files.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_COV_COVERAGESUMMARYINFO_H
|
|
#define LLVM_COV_COVERAGESUMMARYINFO_H
|
|
|
|
#include "FunctionCoverageMapping.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
namespace llvm {
|
|
|
|
/// \brief Provides information about region coverage for a function/file.
|
|
struct RegionCoverageInfo {
|
|
/// \brief The number of regions that were executed at least once.
|
|
size_t Covered;
|
|
|
|
/// \brief The number of regions that weren't executed.
|
|
size_t NotCovered;
|
|
|
|
/// \brief The total number of regions in a function/file.
|
|
size_t NumRegions;
|
|
|
|
RegionCoverageInfo(size_t Covered, size_t NumRegions)
|
|
: Covered(Covered), NotCovered(NumRegions - Covered),
|
|
NumRegions(NumRegions) {}
|
|
|
|
bool isFullyCovered() const { return Covered == NumRegions; }
|
|
|
|
double getPercentCovered() const {
|
|
return double(Covered) / double(NumRegions) * 100.0;
|
|
}
|
|
};
|
|
|
|
/// \brief Provides information about line coverage for a function/file.
|
|
struct LineCoverageInfo {
|
|
/// \brief The number of lines that were executed at least once.
|
|
size_t Covered;
|
|
|
|
/// \brief The number of lines that weren't executed.
|
|
size_t NotCovered;
|
|
|
|
/// \brief The number of lines that aren't code.
|
|
size_t NonCodeLines;
|
|
|
|
/// \brief The total number of lines in a function/file.
|
|
size_t NumLines;
|
|
|
|
LineCoverageInfo(size_t Covered, size_t NumNonCodeLines, size_t NumLines)
|
|
: Covered(Covered), NotCovered(NumLines - NumNonCodeLines - Covered),
|
|
NonCodeLines(NumNonCodeLines), NumLines(NumLines) {}
|
|
|
|
bool isFullyCovered() const { return Covered == (NumLines - NonCodeLines); }
|
|
|
|
double getPercentCovered() const {
|
|
return double(Covered) / double(NumLines - NonCodeLines) * 100.0;
|
|
}
|
|
};
|
|
|
|
/// \brief Provides information about function coverage for a file.
|
|
struct FunctionCoverageInfo {
|
|
/// \brief The number of functions that have full
|
|
/// region coverage.
|
|
size_t FullyCovered;
|
|
|
|
/// \brief The total number of functions in this file.
|
|
size_t NumFunctions;
|
|
|
|
FunctionCoverageInfo(size_t FullyCovered, size_t NumFunctions)
|
|
: FullyCovered(FullyCovered), NumFunctions(NumFunctions) {}
|
|
|
|
bool isFullyCovered() const { return FullyCovered == NumFunctions; }
|
|
|
|
double getPercentCovered() const {
|
|
return double(FullyCovered) / double(NumFunctions) * 100.0;
|
|
}
|
|
};
|
|
|
|
/// \brief A summary of function's code coverage.
|
|
struct FunctionCoverageSummary {
|
|
StringRef Name;
|
|
RegionCoverageInfo RegionCoverage;
|
|
LineCoverageInfo LineCoverage;
|
|
|
|
FunctionCoverageSummary(StringRef Name,
|
|
const RegionCoverageInfo &RegionCoverage,
|
|
const LineCoverageInfo &LineCoverage)
|
|
: Name(Name), RegionCoverage(RegionCoverage), LineCoverage(LineCoverage) {
|
|
}
|
|
|
|
/// \brief Compute the code coverage summary for the given function coverage
|
|
/// mapping record.
|
|
static FunctionCoverageSummary get(const FunctionCoverageMapping &Function);
|
|
};
|
|
|
|
/// \brief A summary of file's code coverage.
|
|
struct FileCoverageSummary {
|
|
StringRef Name;
|
|
RegionCoverageInfo RegionCoverage;
|
|
LineCoverageInfo LineCoverage;
|
|
FunctionCoverageInfo FunctionCoverage;
|
|
/// \brief The summary of every function
|
|
/// in this file.
|
|
ArrayRef<FunctionCoverageSummary> FunctionSummaries;
|
|
|
|
FileCoverageSummary(StringRef Name, const RegionCoverageInfo &RegionCoverage,
|
|
const LineCoverageInfo &LineCoverage,
|
|
const FunctionCoverageInfo &FunctionCoverage,
|
|
ArrayRef<FunctionCoverageSummary> FunctionSummaries)
|
|
: Name(Name), RegionCoverage(RegionCoverage), LineCoverage(LineCoverage),
|
|
FunctionCoverage(FunctionCoverage),
|
|
FunctionSummaries(FunctionSummaries) {}
|
|
|
|
/// \brief Compute the code coverage summary for a file.
|
|
static FileCoverageSummary
|
|
get(StringRef Name, ArrayRef<FunctionCoverageSummary> FunctionSummaries);
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_COV_COVERAGESUMMARYINFO_H
|