Skip to content

Commit 198e677

Browse files
committed
[analyzer] Add option to SATest.py for extra checkers
This patch adds the flag `extra-checkers` to the sub-command `build` for passing a comma separated list of additional checkers to include. Differential Revision: https://reviews.llvm.org/D106739
1 parent 9790a2a commit 198e677

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/utils/analyzer/SATest.py

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def build(parser, args):
4242
projects,
4343
args.override_compiler,
4444
args.extra_analyzer_config,
45+
args.extra_checkers,
4546
args.regenerate,
4647
args.strictness)
4748
tests_passed = tester.test_all()
@@ -250,6 +251,10 @@ def main():
250251
dest="extra_analyzer_config", type=str,
251252
default="",
252253
help="Arguments passed to to -analyzer-config")
254+
build_parser.add_argument("--extra-checkers",
255+
dest="extra_checkers", type=str,
256+
default="",
257+
help="Extra checkers to enable")
253258
build_parser.add_argument("--projects", action="store", default="",
254259
help="Comma-separated list of projects to test")
255260
build_parser.add_argument("--max-size", action="store", default=None,

clang/utils/analyzer/SATestBuild.py

+9
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class TestInfo(NamedTuple):
213213
project: ProjectInfo
214214
override_compiler: bool = False
215215
extra_analyzer_config: str = ""
216+
extra_checkers: str = ""
216217
is_reference_build: bool = False
217218
strictness: int = 0
218219

@@ -233,13 +234,16 @@ class RegressionTester:
233234
"""
234235
A component aggregating all of the project testing.
235236
"""
237+
236238
def __init__(self, jobs: int, projects: List[ProjectInfo],
237239
override_compiler: bool, extra_analyzer_config: str,
240+
extra_checkers: str,
238241
regenerate: bool, strictness: bool):
239242
self.jobs = jobs
240243
self.projects = projects
241244
self.override_compiler = override_compiler
242245
self.extra_analyzer_config = extra_analyzer_config
246+
self.extra_checkers = extra_checkers
243247
self.regenerate = regenerate
244248
self.strictness = strictness
245249

@@ -252,6 +256,7 @@ def test_all(self) -> bool:
252256
TestInfo(project,
253257
self.override_compiler,
254258
self.extra_analyzer_config,
259+
self.extra_checkers,
255260
self.regenerate, self.strictness))
256261
if self.jobs <= 1:
257262
return self._single_threaded_test_all(projects_to_test)
@@ -305,10 +310,12 @@ class ProjectTester:
305310
"""
306311
A component aggregating testing for one project.
307312
"""
313+
308314
def __init__(self, test_info: TestInfo, silent: bool = False):
309315
self.project = test_info.project
310316
self.override_compiler = test_info.override_compiler
311317
self.extra_analyzer_config = test_info.extra_analyzer_config
318+
self.extra_checkers = test_info.extra_checkers
312319
self.is_reference_build = test_info.is_reference_build
313320
self.strictness = test_info.strictness
314321
self.silent = silent
@@ -414,6 +421,8 @@ def scan_build(self, directory: str, output_dir: str,
414421
if 'SA_ADDITIONAL_CHECKERS' in os.environ:
415422
all_checkers = (all_checkers + ',' +
416423
os.environ['SA_ADDITIONAL_CHECKERS'])
424+
if self.extra_checkers != "":
425+
all_checkers += "," + self.extra_checkers
417426

418427
# Run scan-build from within the patched source directory.
419428
cwd = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)

0 commit comments

Comments
 (0)