llvm.org GIT mirror llvm / 7b18a76
[Coverage] Mark a few more methods const (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275514 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 4 years ago
3 changed file(s) with 20 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
479479 ///
480480 /// Functions that are instantiated more than once, such as C++ template
481481 /// specializations, have distinct coverage records for each instantiation.
482 std::vector getInstantiations(StringRef Filename);
482 std::vector
483 getInstantiations(StringRef Filename) const;
483484
484485 /// \brief Get the coverage for a particular function.
485 CoverageData getCoverageForFunction(const FunctionRecord &Function);
486 CoverageData getCoverageForFunction(const FunctionRecord &Function) const;
486487
487488 /// \brief Get the coverage for an expansion within a coverage set.
488 CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion);
489 CoverageData getCoverageForExpansion(const ExpansionRecord &Expansion) const;
489490 };
490491
491492 // Profile coverage map has the following layout:
477477 }
478478
479479 std::vector
480 CoverageMapping::getInstantiations(StringRef Filename) {
480 CoverageMapping::getInstantiations(StringRef Filename) const {
481481 FunctionInstantiationSetCollector InstantiationSetCollector;
482482 for (const auto &Function : Functions) {
483483 auto MainFileID = findMainViewFileID(Filename, Function);
497497 }
498498
499499 CoverageData
500 CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) {
500 CoverageMapping::getCoverageForFunction(const FunctionRecord &Function) const {
501501 auto MainFileID = findMainViewFileID(Function);
502502 if (!MainFileID)
503503 return CoverageData();
517517 return FunctionCoverage;
518518 }
519519
520 CoverageData
521 CoverageMapping::getCoverageForExpansion(const ExpansionRecord &Expansion) {
520 CoverageData CoverageMapping::getCoverageForExpansion(
521 const ExpansionRecord &Expansion) const {
522522 CoverageData ExpansionCoverage(
523523 Expansion.Function.Filenames[Expansion.FileID]);
524524 std::vector Regions;
6666 /// \brief Create source views for the expansions of the view.
6767 void attachExpansionSubViews(SourceCoverageView &View,
6868 ArrayRef Expansions,
69 CoverageMapping &Coverage);
69 const CoverageMapping &Coverage);
7070
7171 /// \brief Create the source view of a particular function.
7272 std::unique_ptr
73 createFunctionView(const FunctionRecord &Function, CoverageMapping &Coverage);
73 createFunctionView(const FunctionRecord &Function,
74 const CoverageMapping &Coverage);
7475
7576 /// \brief Create the main source view of a particular source file.
7677 std::unique_ptr
77 createSourceFileView(StringRef SourceFile, CoverageMapping &Coverage);
78
79 /// \brief Load the coverage mapping data. Return true if an error occured.
78 createSourceFileView(StringRef SourceFile, const CoverageMapping &Coverage);
79
80 /// \brief Load the coverage mapping data. Return nullptr if an error occured.
8081 std::unique_ptr load();
8182
8283 int run(Command Cmd, int argc, const char **argv);
167168 return *LoadedSourceFiles.back().second;
168169 }
169170
170 void
171 CodeCoverageTool::attachExpansionSubViews(SourceCoverageView &View,
172 ArrayRef Expansions,
173 CoverageMapping &Coverage) {
171 void CodeCoverageTool::attachExpansionSubViews(
172 SourceCoverageView &View, ArrayRef Expansions,
173 const CoverageMapping &Coverage) {
174174 if (!ViewOpts.ShowExpandedRegions)
175175 return;
176176 for (const auto &Expansion : Expansions) {
192192
193193 std::unique_ptr
194194 CodeCoverageTool::createFunctionView(const FunctionRecord &Function,
195 CoverageMapping &Coverage) {
195 const CoverageMapping &Coverage) {
196196 auto FunctionCoverage = Coverage.getCoverageForFunction(Function);
197197 if (FunctionCoverage.empty())
198198 return nullptr;
210210
211211 std::unique_ptr
212212 CodeCoverageTool::createSourceFileView(StringRef SourceFile,
213 CoverageMapping &Coverage) {
213 const CoverageMapping &Coverage) {
214214 auto SourceBuffer = getSourceFile(SourceFile);
215215 if (!SourceBuffer)
216216 return nullptr;
223223 ViewOpts, std::move(FileCoverage));
224224 attachExpansionSubViews(*View, Expansions, Coverage);
225225
226 for (auto Function : Coverage.getInstantiations(SourceFile)) {
226 for (const auto *Function : Coverage.getInstantiations(SourceFile)) {
227227 auto SubViewCoverage = Coverage.getCoverageForFunction(*Function);
228228 auto SubViewExpansions = SubViewCoverage.getExpansions();
229229 auto SubView =