Page MenuHomePhabricator

No OneTemporary

diff --git a/.arclint b/.arclint
index 1beb94860d..9a073359bd 100644
--- a/.arclint
+++ b/.arclint
@@ -1,65 +1,72 @@
{
"linters": {
"generated": {
"type": "generated"
},
"clang-format": {
"type": "clang-format",
"version": "7.0",
"bin": ["clang-format-7", "clang-format"],
"include": "(^src/.*\\.(h|c|cpp)$)",
"exclude": [
"(^src/(secp256k1|univalue|leveldb)/)"
]
},
"autopep8": {
"type": "autopep8",
"version": ">=1.3.4",
"include": "(\\.py$)"
},
"flake8": {
"type": "flake8",
"include": "(\\.py$)",
"flags": [
"--select=F401,F403,F405"
]
},
"lint-format-strings": {
"type": "lint-format-strings",
"include": "(^src/.*\\.(h|c|cpp)$)",
"exclude": [
"(^src/(secp256k1|univalue|leveldb)/)"
]
},
"check-doc": {
"type": "check-doc",
"include": "(^src/.*\\.(h|c|cpp)$)"
},
"lint-tests": {
"type": "lint-tests",
"include": "(^src/(rpc/|wallet/)?test/.*\\.(cpp)$)"
},
"lint-python-format": {
"type": "lint-python-format",
"include": "(\\.py$)",
"exclude": [
"(^test/lint/lint-python-format\\.py$)"
]
},
"phpcs": {
"type": "phpcs",
"include": "(\\.php$)",
"exclude": [
"(^arcanist/__phutil_library_.+\\.php$)"
],
"phpcs.standard": "arcanist/linter/phpcs_ruleset.xml"
},
"lint-locale-dependence": {
"type": "lint-locale-dependence",
"include": "(^src/.*\\.(h|cpp)$)",
"exclude": [
"(^src/(crypto/ctaes/|leveldb/|secp256k1/|seeder/|tinyformat.h|univalue/))"
]
+ },
+ "lint-cheader": {
+ "type": "lint-cheader",
+ "include": "(^src/.*\\.(h|cpp)$)",
+ "exclude": [
+ "(^src/(crypto/ctaes|secp256k1|univalue|leveldb)/)"
+ ]
}
}
}
diff --git a/arcanist/.phutil_module_cache b/arcanist/.phutil_module_cache
index f7590d1bc4..034f7636f4 100644
--- a/arcanist/.phutil_module_cache
+++ b/arcanist/.phutil_module_cache
@@ -1 +1 @@
-{"__symbol_cache_version__":11,"90a8b110dc475955f15bb81d37268cb5":{"have":{"class":{"AutoPEP8FormatLinter":75}},"need":{"function":{"pht":297,"execx":769,"id":1903},"class":{"ArcanistExternalLinter":104,"ArcanistLintMessage":1910,"Filesystem":1754,"ArcanistLinter":2017,"ArcanistLintSeverity":2095}},"xmap":{"AutoPEP8FormatLinter":["ArcanistExternalLinter"]}},"bf0805c02029a7226e8c0d7dee039b3c":{"have":{"class":{"CheckDocLinter":106}},"need":{"function":{"pht":323,"id":1847},"class":{"ArcanistExternalLinter":129,"ArcanistLintMessage":1854,"Filesystem":731,"ArcanistLinter":1902,"ArcanistLintSeverity":1988}},"xmap":{"CheckDocLinter":["ArcanistExternalLinter"]}},"6af7410cfea496ff1d4dcc2624b6b8ea":{"have":{"class":{"ClangFormatLinter":79}},"need":{"function":{"pht":302,"execx":781,"id":1653},"class":{"ArcanistExternalLinter":105,"ArcanistLintMessage":1660,"Filesystem":1504,"ArcanistLinter":1767,"ArcanistLintSeverity":1845}},"xmap":{"ClangFormatLinter":["ArcanistExternalLinter"]}},"9285ad9415f8ebe564f7119e5a72c559":{"have":{"class":{"FormatStringLinter":146}},"need":{"function":{"pht":377,"csprintf":1492,"id":1872},"class":{"ArcanistExternalLinter":173,"ArcanistLintMessage":1879,"Filesystem":827,"ArcanistLinter":1956,"ArcanistLintSeverity":2044}},"xmap":{"FormatStringLinter":["ArcanistExternalLinter"]}},"6f2f22dd0f259fb2eaa284b4fab3bc29":{"have":{"class":{"PythonFormatLinter":123}},"need":{"function":{"pht":353,"id":1838},"class":{"ArcanistExternalLinter":150,"ArcanistLintMessage":1845,"Filesystem":776,"ArcanistLinter":1970,"ArcanistLintSeverity":2053}},"xmap":{"PythonFormatLinter":["ArcanistExternalLinter"]}},"25781df78f6eebfb223296b8265e9d19":{"have":{"class":{"TestsLinter":103}},"need":{"function":{"pht":318,"id":2629},"class":{"ArcanistExternalLinter":123,"ArcanistLintMessage":2636,"Filesystem":776,"ArcanistLinter":2684,"ArcanistLintSeverity":2792}},"xmap":{"TestsLinter":["ArcanistExternalLinter"]}},"224d394856b17878058b4c14acb7178b":{"have":{"class":{"LocaleDependenceLinter":160}},"need":{"function":{"pht":5400},"class":{"ArcanistLinter":191,"ArcanistLintSeverity":5903,"Filesystem":6149}},"xmap":{"LocaleDependenceLinter":["ArcanistLinter"]}}}
\ No newline at end of file
+{"__symbol_cache_version__":11,"90a8b110dc475955f15bb81d37268cb5":{"have":{"class":{"AutoPEP8FormatLinter":75}},"need":{"function":{"pht":297,"execx":769,"id":1903},"class":{"ArcanistExternalLinter":104,"ArcanistLintMessage":1910,"Filesystem":1754,"ArcanistLinter":2017,"ArcanistLintSeverity":2095}},"xmap":{"AutoPEP8FormatLinter":["ArcanistExternalLinter"]}},"bf0805c02029a7226e8c0d7dee039b3c":{"have":{"class":{"CheckDocLinter":106}},"need":{"function":{"pht":323,"id":1847},"class":{"ArcanistExternalLinter":129,"ArcanistLintMessage":1854,"Filesystem":731,"ArcanistLinter":1902,"ArcanistLintSeverity":1988}},"xmap":{"CheckDocLinter":["ArcanistExternalLinter"]}},"6af7410cfea496ff1d4dcc2624b6b8ea":{"have":{"class":{"ClangFormatLinter":79}},"need":{"function":{"pht":302,"execx":781,"id":1653},"class":{"ArcanistExternalLinter":105,"ArcanistLintMessage":1660,"Filesystem":1504,"ArcanistLinter":1767,"ArcanistLintSeverity":1845}},"xmap":{"ClangFormatLinter":["ArcanistExternalLinter"]}},"9285ad9415f8ebe564f7119e5a72c559":{"have":{"class":{"FormatStringLinter":146}},"need":{"function":{"pht":377,"csprintf":1492,"id":1872},"class":{"ArcanistExternalLinter":173,"ArcanistLintMessage":1879,"Filesystem":827,"ArcanistLinter":1956,"ArcanistLintSeverity":2044}},"xmap":{"FormatStringLinter":["ArcanistExternalLinter"]}},"224d394856b17878058b4c14acb7178b":{"have":{"class":{"LocaleDependenceLinter":160}},"need":{"function":{"pht":5400},"class":{"ArcanistLinter":191,"ArcanistLintSeverity":5903,"Filesystem":6149}},"xmap":{"LocaleDependenceLinter":["ArcanistLinter"]}},"6f2f22dd0f259fb2eaa284b4fab3bc29":{"have":{"class":{"PythonFormatLinter":123}},"need":{"function":{"pht":353,"id":1838},"class":{"ArcanistExternalLinter":150,"ArcanistLintMessage":1845,"Filesystem":776,"ArcanistLinter":1970,"ArcanistLintSeverity":2053}},"xmap":{"PythonFormatLinter":["ArcanistExternalLinter"]}},"25781df78f6eebfb223296b8265e9d19":{"have":{"class":{"TestsLinter":103}},"need":{"function":{"pht":318,"id":2629},"class":{"ArcanistExternalLinter":123,"ArcanistLintMessage":2636,"Filesystem":776,"ArcanistLinter":2684,"ArcanistLintSeverity":2792}},"xmap":{"TestsLinter":["ArcanistExternalLinter"]}},"38f0c676bff5192a344464142caaa253":{"have":{"class":{"CHeaderLinter":99}},"need":{"function":{"pht":611},"class":{"ArcanistLinter":121,"ArcanistLintSeverity":1060,"Filesystem":1307}},"xmap":{"CHeaderLinter":["ArcanistLinter"]}}}
\ No newline at end of file
diff --git a/arcanist/__phutil_library_map__.php b/arcanist/__phutil_library_map__.php
index 4ba3c22173..bd41fa60e5 100644
--- a/arcanist/__phutil_library_map__.php
+++ b/arcanist/__phutil_library_map__.php
@@ -1,30 +1,32 @@
<?php
/**
* This file is automatically generated. Use 'arc liberate' to rebuild it.
*
* @generated
* @phutil-library-version 2
*/
phutil_register_library_map(array(
'__library_version__' => 2,
'class' => array(
'AutoPEP8FormatLinter' => 'linter/AutoPEP8Linter.php',
+ 'CHeaderLinter' => 'linter/CHeaderLinter.php',
'CheckDocLinter' => 'linter/CheckDocLinter.php',
'ClangFormatLinter' => 'linter/ClangFormatLinter.php',
'FormatStringLinter' => 'linter/FormatStringLinter.php',
'LocaleDependenceLinter' => 'linter/LocaleDependenceLinter.php',
'PythonFormatLinter' => 'linter/PythonFormatLinter.php',
'TestsLinter' => 'linter/TestsLinter.php',
),
'function' => array(),
'xmap' => array(
'AutoPEP8FormatLinter' => 'ArcanistExternalLinter',
+ 'CHeaderLinter' => 'ArcanistLinter',
'CheckDocLinter' => 'ArcanistExternalLinter',
'ClangFormatLinter' => 'ArcanistExternalLinter',
'FormatStringLinter' => 'ArcanistExternalLinter',
'LocaleDependenceLinter' => 'ArcanistLinter',
'PythonFormatLinter' => 'ArcanistExternalLinter',
'TestsLinter' => 'ArcanistExternalLinter',
),
));
diff --git a/arcanist/linter/CHeaderLinter.php b/arcanist/linter/CHeaderLinter.php
new file mode 100644
index 0000000000..5d3acd852e
--- /dev/null
+++ b/arcanist/linter/CHeaderLinter.php
@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * Enforce using C++ native headers instead of C compatibility headers.
+ */
+final class CHeaderLinter extends ArcanistLinter {
+
+ const CHEADER_FOUND = 1;
+
+ static private $cheaders = array(
+ 'assert',
+ 'ctype',
+ 'errno',
+ 'fenv',
+ 'float',
+ 'inttypes',
+ 'limits',
+ 'locale',
+ 'math',
+ 'setjmp',
+ 'signal',
+ 'stdarg',
+ 'stddef',
+ 'stdint',
+ 'stdio',
+ 'stdlib',
+ 'string',
+ 'time',
+ 'uchar',
+ 'wchar',
+ 'wctype',
+ );
+
+ public function getInfoName() {
+ return 'lint-cheader';
+ }
+
+ public function getInfoDescription() {
+ return pht('Check that C compatility headers are not used in C++ files.');
+ }
+
+ public function getLinterName() {
+ return 'CHEADER';
+ }
+
+ public function getLinterConfigurationName() {
+ return 'lint-cheader';
+ }
+
+ public function getLinterConfigurationOptions() {
+ $options = array();
+ return $options + parent::getLinterConfigurationOptions();
+ }
+
+ public function getLintSeverityMap() {
+ return array(
+ self::CHEADER_FOUND => ArcanistLintSeverity::SEVERITY_AUTOFIX,
+ );
+ }
+
+ public function getLintNameMap() {
+ return array(
+ self::CHEADER_FOUND => pht('C compatibility header found in a C++ file'),
+ );
+ }
+
+ public function lintPath($path) {
+ $path = Filesystem::resolvePath($path, $this->getProjectRoot());
+ $fileContent = Filesystem::readFile($path);
+
+ $anyHeaderPattern = implode('|', self::$cheaders);
+
+ if (!preg_match_all("/#include <($anyHeaderPattern).h>/", $fileContent,
+ $matches, PREG_OFFSET_CAPTURE)) {
+ return;
+ }
+
+ foreach ($matches[1] as $match) {
+ list($header, $offset) = $match;
+ $original = $header.'.h';
+ $replacement = 'c'.$header;
+
+ $this->raiseLintAtOffset(
+ $offset,
+ self::CHEADER_FOUND,
+ pht(
+ 'Use C++ header <%s> instead of C compatibility header <%s>',
+ $replacement, $original),
+ $original,
+ $replacement);
+ }
+ }
+}

File Metadata

Mime Type
text/x-diff
Expires
Wed, May 21, 18:42 (22 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5865717
Default Alt Text
(10 KB)

Event Timeline