Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mode where CTU files are retained #4413

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions analyzer/codechecker_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def perform_analysis(args, skip_handlers, filter_handlers,

ctu_collect = False
ctu_analyze = False
ctu_delete = False
ctu_dir = ''
if 'ctu_phases' in args:
ctu_dir = os.path.join(args.output_path, 'ctu-dir')
Expand All @@ -157,6 +158,7 @@ def perform_analysis(args, skip_handlers, filter_handlers,
return
ctu_collect = args.ctu_phases[0]
ctu_analyze = args.ctu_phases[1]
ctu_delete = args.ctu_phases[2]

if 'stats_enabled' in args and args.stats_enabled:
if ClangSA.ANALYZER_NAME not in analyzers:
Expand Down Expand Up @@ -271,9 +273,9 @@ def perform_analysis(args, skip_handlers, filter_handlers,
makefile_creator.create(actions)
return

if ctu_collect:
if ctu_delete:
shutil.rmtree(ctu_dir, ignore_errors=True)
elif ctu_analyze and not os.path.exists(ctu_dir):
elif not ctu_collect and ctu_analyze and not os.path.exists(ctu_dir):
LOG.error("CTU directory: '%s' does not exist.", ctu_dir)
return

Expand Down Expand Up @@ -363,7 +365,7 @@ def perform_analysis(args, skip_handlers, filter_handlers,
metadata_tool['timestamps'] = {'begin': start_time,
'end': end_time}

if ctu_collect and ctu_analyze:
if ctu_delete:
shutil.rmtree(ctu_dir, ignore_errors=True)

manager.shutdown()
16 changes: 13 additions & 3 deletions analyzer/codechecker_analyzer/cmd/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,18 +537,28 @@ def add_arguments_to_parser(parser):
ctu_modes = ctu_opts.add_mutually_exclusive_group()
ctu_modes.add_argument('--ctu', '--ctu-all',
action='store_const',
const=[True, True],
const=[True, True, True],
dest='ctu_phases',
default=argparse.SUPPRESS,
help="Perform Cross Translation Unit (CTU) "
"analysis, both 'collect' and 'analyze' "
"phases. In this mode, the extra files "
"created by 'collect' are cleaned up "
"after the analysis.")
ctu_modes.add_argument('--ctu-retain',
action='store_const',
const=[True, True, False],
dest='ctu_phases',
default=argparse.SUPPRESS,
help="Perform Cross Translation Unit (CTU) "
"analysis, both 'collect' and 'analyze' "
"phases. In this mode, the extra files "
"created by 'collect' are NOT cleaned up "
"after the analysis.")

ctu_modes.add_argument('--ctu-collect',
action='store_const',
const=[True, False],
const=[True, False, False],
dest='ctu_phases',
default=argparse.SUPPRESS,
help="Perform the first, 'collect' phase of "
Expand All @@ -561,7 +571,7 @@ def add_arguments_to_parser(parser):

ctu_modes.add_argument('--ctu-analyze',
action='store_const',
const=[False, True],
const=[False, True, True],
dest='ctu_phases',
default=argparse.SUPPRESS,
help="Perform the second, 'analyze' phase of "
Expand Down
12 changes: 10 additions & 2 deletions docs/analyzer/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ usage: CodeChecker check [-h] [-o OUTPUT_DIR] [-t {plist}] [-q]
[--analyzer-config [ANALYZER_CONFIG [ANALYZER_CONFIG ...]]]
[--checker-config [CHECKER_CONFIG [CHECKER_CONFIG ...]]]
[--timeout TIMEOUT]
[--ctu | --ctu-collect | --ctu-analyze]
[--ctu | --ctu-retain | --ctu-collect | --ctu-analyze]
[--ctu-reanalyze-on-failure]
[--ctu-ast-mode {load-from-pch,parse-on-demand}]
[-e checker/group/profile] [-d checker/group/profile]
Expand Down Expand Up @@ -333,6 +333,10 @@ cross translation unit analysis arguments:
'collect' and 'analyze' phases. In this mode, the
extra files created by 'collect' are cleaned up after
the analysis.
--ctu-retain Perform Cross Translation Unit (CTU) analysis, both
'collect' and 'analyze' phases. After doing so, the
extra files created by 'collect' are retained after
the analysis and not removed.
--ctu-collect Perform the first, 'collect' phase of Cross-TU
analysis. This phase generates extra files needed by
CTU analysis, and puts them into '<OUTPUT_DIR>/ctu-
Expand Down Expand Up @@ -993,7 +997,7 @@ usage: CodeChecker analyze [-h] [-j JOBS]
[--saargs CLANGSA_ARGS_CFG_FILE]
[--tidyargs TIDY_ARGS_CFG_FILE]
[--timeout TIMEOUT]
[--ctu | --ctu-collect | --ctu-analyze]
[--ctu | --ctu-retain | --ctu-collect | --ctu-analyze]
[--ctu-ast-mode {load-from-pch, parse-on-demand}]
[--ctu-reanalyze-on-failure]
[-e checker/group/profile]
Expand Down Expand Up @@ -1650,6 +1654,10 @@ cross translation unit analysis arguments:
'collect' and 'analyze' phases. In this mode, the
extra files created by 'collect' are cleaned up after
the analysis.
--ctu-retain Perform Cross Translation Unit (CTU) analysis, both
'collect' and 'analyze' phases. After doing so, the
extra files created by 'collect' are retained after
the analysis and not removed.
--ctu-collect Perform the first, 'collect' phase of Cross-TU
analysis. This phase generates extra files needed by
CTU analysis, and puts them into '<OUTPUT_DIR>/ctu-
Expand Down
Loading