Skip to content

Commit

Permalink
[cmd] Do not allow ctu-ast-mode in non-CTU mode
Browse files Browse the repository at this point in the history
Option ctu-ast-mode is only meaningful if ctu mode is active.
Exit early if ctu-ast-mode is specified but ctu mode is not enabled.
  • Loading branch information
gamesh411 committed Jan 15, 2021
1 parent 9b5158f commit eee976c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions analyzer/codechecker_analyzer/cmd/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,12 @@ def main(args):
# Process the skip list if present.
skip_handler = __get_skip_handler(args)

# CTU loading mode is only meaningful if CTU itself is enabled.
if 'ctu_ast_mode' in args and 'ctu_phases' not in args:
LOG.error("Analyzer option 'ctu-ast-mode' requires option 'ctu' to be "
"also set")
sys.exit(1)

# Enable alpha uniqueing by default if ctu analysis is used.
if 'none' in args.compile_uniqueing and 'ctu_phases' in args:
args.compile_uniqueing = "alpha"
Expand Down
11 changes: 11 additions & 0 deletions analyzer/tests/functional/ctu/test_ctu.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import shutil
import unittest

from subprocess import run
from typing import IO

from libtest import env
Expand Down Expand Up @@ -78,6 +79,16 @@ def tearDown(self):
shutil.rmtree(self.report_dir, ignore_errors=True)
os.chdir(self.__old_pwd)

@skipUnlessCTUCapable
def test_ctu_loading_mode_requires_ctu_mode(self):
""" Test ctu-ast-mode option requires ctu mode enabled. """
cmd = [self._codechecker_cmd, 'analyze', '-o', self.report_dir,
'--analyzers', 'clangsa', '--ctu-ast-mode=load-from-pch',
self.buildlog]

self.assertEqual(1,
run(cmd, cwd=self.test_dir, env=self.env).returncode)

@skipUnlessCTUCapable
def test_ctu_all_ast_dump_based(self):
""" Test full CTU AST-dump based analysis. """
Expand Down

0 comments on commit eee976c

Please sign in to comment.