Skip to content

Commit

Permalink
[fix] Fix non-determinism of clang-diagnostic checker appearances
Browse files Browse the repository at this point in the history
Earlier we collected the enabled/disabled checkers in a set which
results non-determinism in the appearance of clang-tidy checkers.
Instead of sets we're using lists now.
  • Loading branch information
bruntib committed Nov 14, 2023
1 parent 472822c commit c3e22d9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ def get_checker_list(self, config) -> Tuple[List[str], List[str]]:
# enable a compiler warning, we first have to undo the -checks level
# disable and then enable it, so we need both
# -checks=compiler-diagnostic- and -W.
compiler_warnings = set()
enabled_checkers = set()
compiler_warnings = list()
enabled_checkers = list()

has_checker_config = \
config.checker_config and config.checker_config != '{}'
Expand All @@ -377,8 +377,8 @@ def get_checker_list(self, config) -> Tuple[List[str], List[str]]:
f"'clang-diagnostic-{checker_name[1:]}' "
"instead.")
if state == CheckerState.enabled:
compiler_warnings.add('-W' + warning_name)
enabled_checkers.add(checker_name)
compiler_warnings.append('-W' + warning_name)
enabled_checkers.append(checker_name)
elif state == CheckerState.disabled:
if config.enable_all:
LOG.warning("Disabling compiler warning with "
Expand All @@ -390,15 +390,15 @@ def get_checker_list(self, config) -> Tuple[List[str], List[str]]:
# as -clang-diagnostic-... .
elif warning_type == CheckerType.analyzer:
if state == CheckerState.enabled:
compiler_warnings.add('-W' + warning_name)
enabled_checkers.add(checker_name)
compiler_warnings.append('-W' + warning_name)
enabled_checkers.append(checker_name)
else:
compiler_warnings.add('-Wno-' + warning_name)
compiler_warnings.append('-Wno-' + warning_name)

continue

if state == CheckerState.enabled:
enabled_checkers.add(checker_name)
enabled_checkers.append(checker_name)

# By default all checkers are disabled and the enabled ones are added
# explicitly.
Expand All @@ -415,7 +415,7 @@ def get_checker_list(self, config) -> Tuple[List[str], List[str]]:
# for the compiler, clang-tidy is just capable to emit them in its own
# format.
if config.analyzer_config.get('take-config-from-directory') == 'true':
return [], list(compiler_warnings)
return [], compiler_warnings

if has_checker_config:
try:
Expand All @@ -428,12 +428,12 @@ def get_checker_list(self, config) -> Tuple[List[str], List[str]]:
# valid dictionary.
checker_cfg = ast.literal_eval(config.checker_config.strip())
if checker_cfg.get('Checks'):
return [], list(compiler_warnings)
return [], compiler_warnings
except SyntaxError as ex:
LOG.debug("Invalid checker configuration: %s. Error: %s",
config.checker_config, ex)

return checkers, list(compiler_warnings)
return checkers, compiler_warnings

def construct_analyzer_cmd(self, result_handler):
""" Contruct command which will be executed on analysis. """
Expand Down

0 comments on commit c3e22d9

Please sign in to comment.