Changeset View
Changeset View
Standalone View
Standalone View
llvm-cov/SourceCoverageView.h
Show All 15 Lines | |||||
#include "CoverageViewOptions.h" | #include "CoverageViewOptions.h" | ||||
#include "llvm/ProfileData/Coverage/CoverageMapping.h" | #include "llvm/ProfileData/Coverage/CoverageMapping.h" | ||||
#include "llvm/Support/MemoryBuffer.h" | #include "llvm/Support/MemoryBuffer.h" | ||||
#include <vector> | #include <vector> | ||||
namespace llvm { | namespace llvm { | ||||
typedef StringMap<std::pair<std::vector<std::string>, | |||||
std::unique_ptr<coverage::CoverageMapping>>> | |||||
ObjectFilesMap; | |||||
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; | coverage::CounterMappingRegion Region; | ||||
std::unique_ptr<SourceCoverageView> View; | std::unique_ptr<SourceCoverageView> View; | ||||
ExpansionView(const coverage::CounterMappingRegion &Region, | ExpansionView(const coverage::CounterMappingRegion &Region, | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | public: | ||||
/// \brief Create a file to print a coverage view into. | /// \brief Create a file to print a coverage view into. | ||||
virtual Expected<OwnedStream> createViewFile(StringRef Path, | virtual Expected<OwnedStream> createViewFile(StringRef Path, | ||||
bool InToplevel) = 0; | bool InToplevel) = 0; | ||||
/// \brief Close a file which has been used to print a coverage view. | /// \brief Close a file which has been used to print a coverage view. | ||||
virtual void closeViewFile(OwnedStream OS) = 0; | virtual void closeViewFile(OwnedStream OS) = 0; | ||||
/// \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(ObjectFilesMap &ObjectMappings) = 0; | ||||
const coverage::CoverageMapping &Coverage) = 0; | |||||
/// @} | /// @} | ||||
}; | }; | ||||
/// \brief A code coverage view of a source file or function. | /// \brief A code coverage view of a source file or function. | ||||
/// | /// | ||||
/// A source coverage view and its nested sub-views form a file-oriented | /// A source coverage view and its nested sub-views form a file-oriented | ||||
/// representation of code coverage data. This view can be printed out by a | /// representation of code coverage data. This view can be printed out by a | ||||
/// renderer which implements the Rendering Interface. | /// renderer which implements the Rendering Interface. | ||||
class SourceCoverageView { | class SourceCoverageView { | ||||
/// A function or file name. | /// A function or file name. | ||||
StringRef SourceName; | StringRef SourceName; | ||||
/// All the object files that contain the source file \p SourceName. | |||||
std::vector<std::string> ObjectFilenames; | |||||
/// A memory buffer backing the source on display. | /// A memory buffer backing the source on display. | ||||
const MemoryBuffer &File; | const MemoryBuffer &File; | ||||
/// Various options to guide the coverage renderer. | /// Various options to guide the coverage renderer. | ||||
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; | coverage::CoverageData CoverageInfo; | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | protected: | ||||
static std::string formatCount(uint64_t N); | static std::string formatCount(uint64_t N); | ||||
/// \brief Check if region marker output is expected for a line. | /// \brief Check if region marker output is expected for a line. | ||||
bool shouldRenderRegionMarkers(bool LineHasMultipleRegions) const; | bool shouldRenderRegionMarkers(bool LineHasMultipleRegions) const; | ||||
/// \brief Check if there are any sub-views attached to this view. | /// \brief Check if there are any sub-views attached to this view. | ||||
bool hasSubViews() const; | bool hasSubViews() const; | ||||
SourceCoverageView(StringRef SourceName, const MemoryBuffer &File, | SourceCoverageView(StringRef SourceName, | ||||
ArrayRef<std::string> ObjectFilenames, | |||||
const MemoryBuffer &File, | |||||
const CoverageViewOptions &Options, | const CoverageViewOptions &Options, | ||||
coverage::CoverageData &&CoverageInfo) | coverage::CoverageData &&CoverageInfo) | ||||
: SourceName(SourceName), File(File), Options(Options), | : SourceName(SourceName), ObjectFilenames(ObjectFilenames), File(File), | ||||
CoverageInfo(std::move(CoverageInfo)) {} | Options(Options), 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, | ||||
coverage::CoverageData &&CoverageInfo); | coverage::CoverageData &&CoverageInfo, | ||||
ArrayRef<std::string> ObjectFiles = std::vector<std::string>()); | |||||
virtual ~SourceCoverageView() {} | virtual ~SourceCoverageView() {} | ||||
/// \brief Return the source name formatted for the host OS. | /// \brief Return the source name formatted for the host OS. | ||||
std::string getSourceName() const; | std::string getSourceName() const; | ||||
/// \brief Return a verbose description of the source name and the binary it | /// \brief Return a verbose description of the source name and the binary it | ||||
/// corresponds to. | /// corresponds to. | ||||
Show All 21 Lines |