[llvm] r275514 - [Coverage] Mark a few more methods const (NFC)
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 18:19:33 PDT 2016
Author: vedantk
Date: Thu Jul 14 20:19:33 2016
New Revision: 275514
URL: http://llvm.org/viewvc/llvm-project?rev=275514&view=rev
Log:
[Coverage] Mark a few more methods const (NFC)
Modified:
llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMapping.h
llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp
llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
Modified: llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMapping.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMapping.h?rev=275514&r1=275513&r2=275514&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMapping.h (original)
+++ llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMapping.h Thu Jul 14 20:19:33 2016
@@ -480,13 +480,14 @@ public:
///
/// Functions that are instantiated more than once, such as C++ template
/// specializations, have distinct coverage records for each instantiation.
- std::vector<const FunctionRecord *> getInstantiations(StringRef Filename);
+ std::vector<const FunctionRecord *>
+ getInstantiations(StringRef Filename) const;
/// \brief Get the coverage for a particular function.
- CoverageData getCoverageForFunction(const FunctionRecord &Function);
+ CoverageData getCoverageForFunction(const FunctionRecord &Function) const;
/// \brief Get the coverage for an expansion within a coverage set.
- CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion);
+ CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion) const;
};
// Profile coverage map has the following layout:
Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp?rev=275514&r1=275513&r2=275514&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp (original)
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp Thu Jul 14 20:19:33 2016
@@ -478,7 +478,7 @@ CoverageData CoverageMapping::getCoverag
}
std::vector<const FunctionRecord *>
-CoverageMapping::getInstantiations(StringRef Filename) {
+CoverageMapping::getInstantiations(StringRef Filename) const {
FunctionInstantiationSetCollector InstantiationSetCollector;
for (const auto &Function : Functions) {
auto MainFileID = findMainViewFileID(Filename, Function);
@@ -498,7 +498,7 @@ CoverageMapping::getInstantiations(Strin
}
CoverageData
-CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) {
+CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
auto MainFileID = findMainViewFileID(Function);
if (!MainFileID)
return CoverageData();
@@ -518,8 +518,8 @@ CoverageMapping::getCoverageForFunction(
return FunctionCoverage;
}
-CoverageData
-CoverageMapping::getCoverageForExpansion(const ExpansionRecord &Expansion) {
+CoverageData CoverageMapping::getCoverageForExpansion(
+ const ExpansionRecord &Expansion) const {
CoverageData ExpansionCoverage(
Expansion.Function.Filenames[Expansion.FileID]);
std::vector<coverage::CountedRegion> Regions;
Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=275514&r1=275513&r2=275514&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Thu Jul 14 20:19:33 2016
@@ -67,17 +67,18 @@ public:
/// \brief Create source views for the expansions of the view.
void attachExpansionSubViews(SourceCoverageView &View,
ArrayRef<ExpansionRecord> Expansions,
- CoverageMapping &Coverage);
+ const CoverageMapping &Coverage);
/// \brief Create the source view of a particular function.
std::unique_ptr<SourceCoverageView>
- createFunctionView(const FunctionRecord &Function, CoverageMapping &Coverage);
+ createFunctionView(const FunctionRecord &Function,
+ const CoverageMapping &Coverage);
/// \brief Create the main source view of a particular source file.
std::unique_ptr<SourceCoverageView>
- createSourceFileView(StringRef SourceFile, CoverageMapping &Coverage);
+ createSourceFileView(StringRef SourceFile, const CoverageMapping &Coverage);
- /// \brief Load the coverage mapping data. Return true if an error occured.
+ /// \brief Load the coverage mapping data. Return nullptr if an error occured.
std::unique_ptr<CoverageMapping> load();
int run(Command Cmd, int argc, const char **argv);
@@ -168,10 +169,9 @@ CodeCoverageTool::getSourceFile(StringRe
return *LoadedSourceFiles.back().second;
}
-void
-CodeCoverageTool::attachExpansionSubViews(SourceCoverageView &View,
- ArrayRef<ExpansionRecord> Expansions,
- CoverageMapping &Coverage) {
+void CodeCoverageTool::attachExpansionSubViews(
+ SourceCoverageView &View, ArrayRef<ExpansionRecord> Expansions,
+ const CoverageMapping &Coverage) {
if (!ViewOpts.ShowExpandedRegions)
return;
for (const auto &Expansion : Expansions) {
@@ -193,7 +193,7 @@ CodeCoverageTool::attachExpansionSubView
std::unique_ptr<SourceCoverageView>
CodeCoverageTool::createFunctionView(const FunctionRecord &Function,
- CoverageMapping &Coverage) {
+ const CoverageMapping &Coverage) {
auto FunctionCoverage = Coverage.getCoverageForFunction(Function);
if (FunctionCoverage.empty())
return nullptr;
@@ -211,7 +211,7 @@ CodeCoverageTool::createFunctionView(con
std::unique_ptr<SourceCoverageView>
CodeCoverageTool::createSourceFileView(StringRef SourceFile,
- CoverageMapping &Coverage) {
+ const CoverageMapping &Coverage) {
auto SourceBuffer = getSourceFile(SourceFile);
if (!SourceBuffer)
return nullptr;
@@ -224,7 +224,7 @@ CodeCoverageTool::createSourceFileView(S
ViewOpts, std::move(FileCoverage));
attachExpansionSubViews(*View, Expansions, Coverage);
- for (auto Function : Coverage.getInstantiations(SourceFile)) {
+ for (const auto *Function : Coverage.getInstantiations(SourceFile)) {
auto SubViewCoverage = Coverage.getCoverageForFunction(*Function);
auto SubViewExpansions = SubViewCoverage.getExpansions();
auto SubView =
More information about the llvm-commits
mailing list