Skip to content

Commit

Permalink
Fix a crash where analyzer binaries were absent
Browse files Browse the repository at this point in the history
AnalyzerContext keeps track of the binaries for each analyzer. However,
if the binary isn't found, we don't map None to the respective analyzer,
we simply skip it. This lead to key errors when we called the version
getter function, which I fixed in this patch.
  • Loading branch information
Szelethus committed Oct 26, 2023
1 parent 34a1601 commit 1ef096c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions analyzer/codechecker_analyzer/analyzer_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def __populate_analyzers(self):
if not compiler_binary:
LOG.debug("'%s' binary can not be found in your PATH!",
value)
self.__analyzers[name] = None
continue

self.__analyzers[name] = os.path.realpath(compiler_binary)
Expand Down
4 changes: 4 additions & 0 deletions analyzer/codechecker_analyzer/analyzers/clangsa/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def __add_plugin_load_flags(cls, analyzer_cmd: List[str]):

@classmethod
def get_binary_version(self, environ, details=False) -> str:
# No need to LOG here, we will emit a warning later anyway.
if not self.analyzer_binary():
return None

if details:
version = [self.analyzer_binary(), '--version']
else:
Expand Down
4 changes: 4 additions & 0 deletions analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ def analyzer_binary(cls):

@classmethod
def get_binary_version(self, environ, details=False) -> str:
# No need to LOG here, we will emit a warning later anyway.
if not self.analyzer_binary():
return None

version = [self.analyzer_binary(), '--version']
try:
output = subprocess.check_output(version,
Expand Down
3 changes: 3 additions & 0 deletions analyzer/codechecker_analyzer/analyzers/cppcheck/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def analyzer_binary(cls):
@classmethod
def get_binary_version(self, environ, details=False) -> str:
""" Get analyzer version information. """
# No need to LOG here, we will emit a warning later anyway.
if not self.analyzer_binary():
return None
version = [self.analyzer_binary(), '--version']
try:
output = subprocess.check_output(version,
Expand Down
3 changes: 3 additions & 0 deletions analyzer/codechecker_analyzer/analyzers/gcc/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def get_binary_version(self, environ, details=False) -> str:
"""
Return the analyzer version.
"""
# No need to LOG here, we will emit a warning later anyway.
if not self.analyzer_binary():
return None
if details:
version = [self.analyzer_binary(), '--version']
else:
Expand Down

0 comments on commit 1ef096c

Please sign in to comment.