-
Notifications
You must be signed in to change notification settings - Fork 383
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
[fix] Don't crash when diagtool is missing #4399
base: master
Are you sure you want to change the base?
Conversation
For clang-tidy the set of warnings can be queried by a tool named `diagtool`. In some environments `clang` is a symlink to `ccache`. Since CodeChecker tries to find `diagtool` right next to clang, this logic doesn't work, since `diagtool` is usually not next to `ccache`. In this patch CodeChecker searches `diagtool` in the next element of `PATH` environment variable in case `clang` is a symlink to `ccache`, since `ccache` would do the same, too. Fixes Ericsson#4371
I am getting a similar error: CodeChecker analyze ./compile_commands.json -o reports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some discussion starter comments
@@ -13,8 +13,10 @@ | |||
import ast | |||
import json | |||
import os | |||
from pathlib import Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos for using pathlib
@@ -128,12 +130,28 @@ def get_diagtool_bin(): | |||
if not clang_bin: | |||
return None | |||
|
|||
path_env = os.environ['PATH'].split(os.pathsep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So then we are always expecting PATH to be present?
path_env = os.environ['PATH'].split(os.pathsep) | ||
clang_path = Path(clang_bin) | ||
|
||
if clang_path.resolve().name == 'ccache': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the problem only defined to ccache?
Shouldnt you check if clang_bin is a symlink?
For clang-tidy the set of warnings can be queried by a tool named
diagtool
. In some environmentsclang
is a symlink toccache
. Since CodeChecker tries to finddiagtool
right next to clang, this logic doesn't work, sincediagtool
is usually not next toccache
.In this patch CodeChecker searches
diagtool
in the next element ofPATH
environment variable in caseclang
is a symlink toccache
, sinceccache
would do the same, too.Fixes #4371