Add sub-controls for Hack array compat runtime checks
[hiphop-php.git] / hphp / runtime / base / code-coverage.h
blob5da9e55f8628ce673307c9a319552ad7ff542703
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_EVAL_CODE_COVERAGE_H_
18 #define incl_HPHP_EVAL_CODE_COVERAGE_H_
20 #include "hphp/util/hash-map-typedefs.h"
22 #include <string>
23 #include <vector>
25 namespace HPHP {
26 ///////////////////////////////////////////////////////////////////////////////
28 struct Array;
30 struct CodeCoverage {
31 static constexpr int kLineExecuted = 1;
33 void Record(const char* filename, int line0, int line1);
36 * Returns an array in this format,
38 * array('filename' => array( line => count, ...))
40 * If sys is passed as false, systemlib files are not included.
42 Array Report(bool sys = true);
45 * Write JSON format into the file.
47 * { 'filename': [0, 0, 1, 0, 2, 0], ...}
49 * Note it's 0-indexed, so first count should always be 0.
51 void Report(const std::string& filename);
54 * Clear all coverage data.
56 void Reset();
58 private:
59 typedef hphp_const_char_map<std::vector<int>> CodeCoverageMap;
60 CodeCoverageMap m_hits;
63 ///////////////////////////////////////////////////////////////////////////////
66 #endif // incl_HPHP_EVAL_CODE_COVERAGE_H_