Coverage for /Syzygy/grinder/coverage_data.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%15150.C++source

Line-by-line coverage:

   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    :  #include "syzygy/grinder/coverage_data.h"
  16    :  
  17    :  namespace grinder {
  18    :  
  19  E :  bool CoverageData::Add(const LineInfo& line_info) {
  20    :    // Multiple entries for the same source file are stored consecutively in
  21    :    // the LineInfo, hence we use this as a cache to prevent repeated lookups
  22    :    // of source file names in our SourceFileCoverageDataMap.
  23  E :    const std::string* old_source_file_name = NULL;
  24  E :    SourceFileCoverageDataMap::iterator source_it;
  25    :  
  26    :    LineInfo::SourceLines::const_iterator line_it =
  27  E :        line_info.source_lines().begin();
  28  E :    for (; line_it != line_info.source_lines().end(); ++line_it) {
  29  E :      DCHECK(line_it->source_file_name != NULL);
  30    :  
  31    :      // Different source file? Then insert/lookup in our map.
  32  E :      if (old_source_file_name != line_it->source_file_name) {
  33    :        // We don't care whether it already exists or not.
  34    :        source_it = source_file_coverage_data_map_.insert(
  35    :            std::make_pair(*line_it->source_file_name,
  36  E :                           SourceFileCoverageData())).first;
  37  E :        old_source_file_name = line_it->source_file_name;
  38    :      }
  39    :  
  40    :      // Insert/lookup the execution count by line number.
  41    :      LineExecutionCountMap::iterator line_exec_it =
  42    :          source_it->second.line_execution_count_map.insert(
  43  E :              std::make_pair(line_it->line_number, 0)).first;
  44    :  
  45    :      // Update the execution count using saturation arithmetic.
  46  E :      if (line_it->visit_count > 0) {
  47    :        line_exec_it->second =
  48    :            std::min(line_exec_it->second,
  49    :                     std::numeric_limits<size_t>::max() - line_it->visit_count) +
  50  E :            line_it->visit_count;
  51    :      }
  52  E :    }
  53    :  
  54  E :    return true;
  55  E :  }
  56    :  
  57    :  }  // namespace grinder

Coverage information generated Thu Jan 14 17:40:38 2016.