1 : // Copyright 2012 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares CoverageData, a utility class for accumulating coverage info with
16 : // a file and line centric indexing.
17 :
18 : #ifndef SYZYGY_GRINDER_COVERAGE_DATA_H_
19 : #define SYZYGY_GRINDER_COVERAGE_DATA_H_
20 :
21 : #include <map>
22 :
23 : #include "base/files/file_path.h"
24 : #include "syzygy/grinder/line_info.h"
25 :
26 : namespace grinder {
27 :
28 : // A simple class for accumulating data from LineInfo objects, representing
29 : // it with an alternative index.
30 : class CoverageData {
31 : public:
32 : struct SourceFileCoverageData; // Forward declaration.
33 :
34 : // A map of line numbers to execution counts.
35 : typedef std::map<size_t, uint32> LineExecutionCountMap;
36 : // A map of file names to coverage information.
37 : typedef std::map<std::string, SourceFileCoverageData>
38 : SourceFileCoverageDataMap;
39 :
40 : // Adds the given line information to the internal representation.
41 : // @param line_info the LineInfo object whose coverage information is to be
42 : // merged with our internal representation.
43 : // @returns true on success, false otherwise.
44 : bool Add(const LineInfo& line_info);
45 :
46 E : const SourceFileCoverageDataMap& source_file_coverage_data_map() const {
47 E : return source_file_coverage_data_map_;
48 E : }
49 :
50 : protected:
51 : // Store coverage results, per source file.
52 : SourceFileCoverageDataMap source_file_coverage_data_map_;
53 : };
54 :
55 : // Coverage information that is stored per file. Right now this consists only
56 : // of line execution data, but branch and function data could be added.
57 : struct CoverageData::SourceFileCoverageData {
58 : LineExecutionCountMap line_execution_count_map;
59 : };
60 :
61 : } // namespace grinder
62 :
63 : #endif // SYZYGY_GRINDER_COVERAGE_DATA_H_
|