[clang] 198e677 - [analyzer] Add option to SATest.py for extra checkers

Deep Majumder via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 16 22:13:26 PDT 2021


Author: Deep Majumder
Date: 2021-08-17T10:42:57+05:30
New Revision: 198e6771e24fb5d8d9f3b155445ecc2a4f211004

URL: https://github.com/llvm/llvm-project/commit/198e6771e24fb5d8d9f3b155445ecc2a4f211004
DIFF: https://github.com/llvm/llvm-project/commit/198e6771e24fb5d8d9f3b155445ecc2a4f211004.diff

LOG: [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

Added: 
    

Modified: 
    clang/utils/analyzer/SATest.py
    clang/utils/analyzer/SATestBuild.py

Removed: 
    


################################################################################
diff  --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index 176fe40a2b171..9931870b3b0dd 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -42,6 +42,7 @@ def build(parser, args):
                                           projects,
                                           args.override_compiler,
                                           args.extra_analyzer_config,
+                                          args.extra_checkers,
                                           args.regenerate,
                                           args.strictness)
     tests_passed = tester.test_all()
@@ -250,6 +251,10 @@ def main():
                               dest="extra_analyzer_config", type=str,
                               default="",
                               help="Arguments passed to to -analyzer-config")
+    build_parser.add_argument("--extra-checkers",
+                              dest="extra_checkers", type=str,
+                              default="",
+                              help="Extra checkers to enable")
     build_parser.add_argument("--projects", action="store", default="",
                               help="Comma-separated list of projects to test")
     build_parser.add_argument("--max-size", action="store", default=None,

diff  --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index ed5c7379bb5b4..1977a8fc2aeff 100644
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -213,6 +213,7 @@ class TestInfo(NamedTuple):
     project: ProjectInfo
     override_compiler: bool = False
     extra_analyzer_config: str = ""
+    extra_checkers: str = ""
     is_reference_build: bool = False
     strictness: int = 0
 
@@ -233,13 +234,16 @@ class RegressionTester:
     """
     A component aggregating all of the project testing.
     """
+
     def __init__(self, jobs: int, projects: List[ProjectInfo],
                  override_compiler: bool, extra_analyzer_config: str,
+                 extra_checkers: str,
                  regenerate: bool, strictness: bool):
         self.jobs = jobs
         self.projects = projects
         self.override_compiler = override_compiler
         self.extra_analyzer_config = extra_analyzer_config
+        self.extra_checkers = extra_checkers
         self.regenerate = regenerate
         self.strictness = strictness
 
@@ -252,6 +256,7 @@ def test_all(self) -> bool:
                 TestInfo(project,
                          self.override_compiler,
                          self.extra_analyzer_config,
+                         self.extra_checkers,
                          self.regenerate, self.strictness))
         if self.jobs <= 1:
             return self._single_threaded_test_all(projects_to_test)
@@ -305,10 +310,12 @@ class ProjectTester:
     """
     A component aggregating testing for one project.
     """
+
     def __init__(self, test_info: TestInfo, silent: bool = False):
         self.project = test_info.project
         self.override_compiler = test_info.override_compiler
         self.extra_analyzer_config = test_info.extra_analyzer_config
+        self.extra_checkers = test_info.extra_checkers
         self.is_reference_build = test_info.is_reference_build
         self.strictness = test_info.strictness
         self.silent = silent
@@ -414,6 +421,8 @@ def scan_build(self, directory: str, output_dir: str,
         if 'SA_ADDITIONAL_CHECKERS' in os.environ:
             all_checkers = (all_checkers + ',' +
                             os.environ['SA_ADDITIONAL_CHECKERS'])
+        if self.extra_checkers != "":
+            all_checkers += "," + self.extra_checkers
 
         # Run scan-build from within the patched source directory.
         cwd = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)


        


More information about the cfe-commits mailing list