mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-23 11:04:49 +00:00
[llvm-cov] Use the coverage namespace. NFC.
This is a simple code cleanup. It will facilitate moving LineCoverageIterator to libCoverage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e03fc7c67e
commit
34ea0deeb1
@ -84,10 +84,9 @@ CoveragePrinter::create(const CoverageViewOptions &Opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned SourceCoverageView::getFirstUncoveredLineNo() {
|
unsigned SourceCoverageView::getFirstUncoveredLineNo() {
|
||||||
const auto MinSegIt =
|
const auto MinSegIt = find_if(CoverageInfo, [](const CoverageSegment &S) {
|
||||||
find_if(CoverageInfo, [](const coverage::CoverageSegment &S) {
|
return S.HasCount && S.Count == 0;
|
||||||
return S.HasCount && S.Count == 0;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// There is no uncovered line, return zero.
|
// There is no uncovered line, return zero.
|
||||||
if (MinSegIt == CoverageInfo.end())
|
if (MinSegIt == CoverageInfo.end())
|
||||||
@ -132,7 +131,7 @@ bool SourceCoverageView::hasSubViews() const {
|
|||||||
std::unique_ptr<SourceCoverageView>
|
std::unique_ptr<SourceCoverageView>
|
||||||
SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
|
SourceCoverageView::create(StringRef SourceName, const MemoryBuffer &File,
|
||||||
const CoverageViewOptions &Options,
|
const CoverageViewOptions &Options,
|
||||||
coverage::CoverageData &&CoverageInfo) {
|
CoverageData &&CoverageInfo) {
|
||||||
switch (Options.Format) {
|
switch (Options.Format) {
|
||||||
case CoverageViewOptions::OutputFormat::Text:
|
case CoverageViewOptions::OutputFormat::Text:
|
||||||
return llvm::make_unique<SourceCoverageViewText>(
|
return llvm::make_unique<SourceCoverageViewText>(
|
||||||
@ -152,7 +151,7 @@ std::string SourceCoverageView::getSourceName() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SourceCoverageView::addExpansion(
|
void SourceCoverageView::addExpansion(
|
||||||
const coverage::CounterMappingRegion &Region,
|
const CounterMappingRegion &Region,
|
||||||
std::unique_ptr<SourceCoverageView> View) {
|
std::unique_ptr<SourceCoverageView> View) {
|
||||||
ExpansionSubViews.emplace_back(Region, std::move(View));
|
ExpansionSubViews.emplace_back(Region, std::move(View));
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,17 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
using namespace coverage;
|
||||||
|
|
||||||
class CoverageFiltersMatchAll;
|
class CoverageFiltersMatchAll;
|
||||||
class SourceCoverageView;
|
class SourceCoverageView;
|
||||||
|
|
||||||
/// \brief A view that represents a macro or include expansion.
|
/// \brief A view that represents a macro or include expansion.
|
||||||
struct ExpansionView {
|
struct ExpansionView {
|
||||||
coverage::CounterMappingRegion Region;
|
CounterMappingRegion Region;
|
||||||
std::unique_ptr<SourceCoverageView> View;
|
std::unique_ptr<SourceCoverageView> View;
|
||||||
|
|
||||||
ExpansionView(const coverage::CounterMappingRegion &Region,
|
ExpansionView(const CounterMappingRegion &Region,
|
||||||
std::unique_ptr<SourceCoverageView> View)
|
std::unique_ptr<SourceCoverageView> View)
|
||||||
: Region(Region), View(std::move(View)) {}
|
: Region(Region), View(std::move(View)) {}
|
||||||
ExpansionView(ExpansionView &&RHS)
|
ExpansionView(ExpansionView &&RHS)
|
||||||
@ -112,7 +114,7 @@ public:
|
|||||||
|
|
||||||
/// \brief Create an index which lists reports for the given source files.
|
/// \brief Create an index which lists reports for the given source files.
|
||||||
virtual Error createIndexFile(ArrayRef<std::string> SourceFiles,
|
virtual Error createIndexFile(ArrayRef<std::string> SourceFiles,
|
||||||
const coverage::CoverageMapping &Coverage,
|
const CoverageMapping &Coverage,
|
||||||
const CoverageFiltersMatchAll &Filters) = 0;
|
const CoverageFiltersMatchAll &Filters) = 0;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
@ -134,7 +136,7 @@ class SourceCoverageView {
|
|||||||
const CoverageViewOptions &Options;
|
const CoverageViewOptions &Options;
|
||||||
|
|
||||||
/// Complete coverage information about the source on display.
|
/// Complete coverage information about the source on display.
|
||||||
coverage::CoverageData CoverageInfo;
|
CoverageData CoverageInfo;
|
||||||
|
|
||||||
/// A container for all expansions (e.g macros) in the source on display.
|
/// A container for all expansions (e.g macros) in the source on display.
|
||||||
std::vector<ExpansionView> ExpansionSubViews;
|
std::vector<ExpansionView> ExpansionSubViews;
|
||||||
@ -154,7 +156,7 @@ protected:
|
|||||||
LineRef(StringRef Line, int64_t LineNo) : Line(Line), LineNo(LineNo) {}
|
LineRef(StringRef Line, int64_t LineNo) : Line(Line), LineNo(LineNo) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using CoverageSegmentArray = ArrayRef<const coverage::CoverageSegment *>;
|
using CoverageSegmentArray = ArrayRef<const CoverageSegment *>;
|
||||||
|
|
||||||
/// @name Rendering Interface
|
/// @name Rendering Interface
|
||||||
/// @{
|
/// @{
|
||||||
@ -230,15 +232,14 @@ protected:
|
|||||||
|
|
||||||
SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
|
SourceCoverageView(StringRef SourceName, const MemoryBuffer &File,
|
||||||
const CoverageViewOptions &Options,
|
const CoverageViewOptions &Options,
|
||||||
coverage::CoverageData &&CoverageInfo)
|
CoverageData &&CoverageInfo)
|
||||||
: SourceName(SourceName), File(File), Options(Options),
|
: SourceName(SourceName), File(File), Options(Options),
|
||||||
CoverageInfo(std::move(CoverageInfo)) {}
|
CoverageInfo(std::move(CoverageInfo)) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<SourceCoverageView>
|
static std::unique_ptr<SourceCoverageView>
|
||||||
create(StringRef SourceName, const MemoryBuffer &File,
|
create(StringRef SourceName, const MemoryBuffer &File,
|
||||||
const CoverageViewOptions &Options,
|
const CoverageViewOptions &Options, CoverageData &&CoverageInfo);
|
||||||
coverage::CoverageData &&CoverageInfo);
|
|
||||||
|
|
||||||
virtual ~SourceCoverageView() {}
|
virtual ~SourceCoverageView() {}
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ public:
|
|||||||
const CoverageViewOptions &getOptions() const { return Options; }
|
const CoverageViewOptions &getOptions() const { return Options; }
|
||||||
|
|
||||||
/// \brief Add an expansion subview to this view.
|
/// \brief Add an expansion subview to this view.
|
||||||
void addExpansion(const coverage::CounterMappingRegion &Region,
|
void addExpansion(const CounterMappingRegion &Region,
|
||||||
std::unique_ptr<SourceCoverageView> View);
|
std::unique_ptr<SourceCoverageView> View);
|
||||||
|
|
||||||
/// \brief Add a function instantiation subview to this view.
|
/// \brief Add a function instantiation subview to this view.
|
||||||
|
@ -365,8 +365,7 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error CoveragePrinterHTML::createIndexFile(
|
Error CoveragePrinterHTML::createIndexFile(
|
||||||
ArrayRef<std::string> SourceFiles,
|
ArrayRef<std::string> SourceFiles, const CoverageMapping &Coverage,
|
||||||
const coverage::CoverageMapping &Coverage,
|
|
||||||
const CoverageFiltersMatchAll &Filters) {
|
const CoverageFiltersMatchAll &Filters) {
|
||||||
// Emit the default stylesheet.
|
// Emit the default stylesheet.
|
||||||
auto CSSOrErr = createOutputStream("style", "css", /*InToplevel=*/true);
|
auto CSSOrErr = createOutputStream("style", "css", /*InToplevel=*/true);
|
||||||
@ -515,7 +514,7 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
|
|||||||
return tag("span", Snippet, Color.getValue());
|
return tag("span", Snippet, Color.getValue());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto CheckIfUncovered = [](const coverage::CoverageSegment *S) {
|
auto CheckIfUncovered = [](const CoverageSegment *S) {
|
||||||
return S && S->HasCount && S->Count == 0;
|
return S && S->HasCount && S->Count == 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
using namespace coverage;
|
||||||
|
|
||||||
struct FileCoverageSummary;
|
struct FileCoverageSummary;
|
||||||
|
|
||||||
/// \brief A coverage printer for html output.
|
/// \brief A coverage printer for html output.
|
||||||
|
@ -29,8 +29,7 @@ void CoveragePrinterText::closeViewFile(OwnedStream OS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error CoveragePrinterText::createIndexFile(
|
Error CoveragePrinterText::createIndexFile(
|
||||||
ArrayRef<std::string> SourceFiles,
|
ArrayRef<std::string> SourceFiles, const CoverageMapping &Coverage,
|
||||||
const coverage::CoverageMapping &Coverage,
|
|
||||||
const CoverageFiltersMatchAll &Filters) {
|
const CoverageFiltersMatchAll &Filters) {
|
||||||
auto OSOrErr = createOutputStream("index", "txt", /*InToplevel=*/true);
|
auto OSOrErr = createOutputStream("index", "txt", /*InToplevel=*/true);
|
||||||
if (Error E = OSOrErr.takeError())
|
if (Error E = OSOrErr.takeError())
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
using namespace coverage;
|
||||||
|
|
||||||
/// \brief A coverage printer for text output.
|
/// \brief A coverage printer for text output.
|
||||||
class CoveragePrinterText : public CoveragePrinter {
|
class CoveragePrinterText : public CoveragePrinter {
|
||||||
public:
|
public:
|
||||||
@ -27,7 +29,7 @@ public:
|
|||||||
void closeViewFile(OwnedStream OS) override;
|
void closeViewFile(OwnedStream OS) override;
|
||||||
|
|
||||||
Error createIndexFile(ArrayRef<std::string> SourceFiles,
|
Error createIndexFile(ArrayRef<std::string> SourceFiles,
|
||||||
const coverage::CoverageMapping &Coverage,
|
const CoverageMapping &Coverage,
|
||||||
const CoverageFiltersMatchAll &Filters) override;
|
const CoverageFiltersMatchAll &Filters) override;
|
||||||
|
|
||||||
CoveragePrinterText(const CoverageViewOptions &Opts)
|
CoveragePrinterText(const CoverageViewOptions &Opts)
|
||||||
@ -77,7 +79,7 @@ class SourceCoverageViewText : public SourceCoverageView {
|
|||||||
public:
|
public:
|
||||||
SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
|
SourceCoverageViewText(StringRef SourceName, const MemoryBuffer &File,
|
||||||
const CoverageViewOptions &Options,
|
const CoverageViewOptions &Options,
|
||||||
coverage::CoverageData &&CoverageInfo)
|
CoverageData &&CoverageInfo)
|
||||||
: SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
|
: SourceCoverageView(SourceName, File, Options, std::move(CoverageInfo)) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user