Skip to content

Commit

Permalink
Merge branch 'Ericsson:master' into branch-2-backup
Browse files Browse the repository at this point in the history
  • Loading branch information
feyruzb authored Oct 29, 2024
2 parents 3d22dfb + 1e9f8f0 commit 0ac3d52
Show file tree
Hide file tree
Showing 48 changed files with 2,284 additions and 295 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ sudo apt-get install \
libssl-dev \
clang-14 \
clang-tidy-14 \
cppcheck
cppcheck

# Source: https://fbinfer.com/docs/getting-started
VERSION=1.1.0; \
curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" \
| sudo tar -C /opt -xJ && \
sudo ln -s "/opt/infer-linux64-v$VERSION/bin/infer" /usr/local/bin/infer

ldd --version
infer help --version

sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 9999
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 9999
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,20 @@ jobs:
if: ${{ matrix.os == 'ubuntu-20.04' }}
run:
sudo apt-get update && sudo apt-get install g++-13 clang clang-tidy cppcheck
# https://github.com/facebook/infer/blob/main/docker/1.1.0/Dockerfile
run:
INFER_VERSION=v1.2.0; \
cd /opt && \
curl -sL \
https://github.com/facebook/infer/releases/download/${INFER_VERSION}/infer-linux-x86_64-${INFER_VERSION}.tar.xz | \
tar xJ && \
rm -f /infer && \
ln -s ${PWD}/infer-linux-x86_64-$INFER_VERSION /infer

- name: "Install run-time dependencies (OSX)"
if: ${{ matrix.os == 'macos-10.15' }}
run:
brew install llvm cppcheck g++-13
brew install llvm cppcheck g++-13 infer

- name: "Install run-time dependencies (Windows)"
if: ${{ matrix.os == 'windows-2019' }}
Expand Down
12 changes: 7 additions & 5 deletions analyzer/codechecker_analyzer/analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def prepare_check(action, analyzer_config, output_dir,


def handle_success(
rh, result_file, result_base, skip_handlers,
rh, result_file, result_base, filter_handlers,
rs_handler: ReviewStatusHandler,
capture_analysis_output, success_dir
):
Expand All @@ -230,7 +230,7 @@ def handle_success(
save_output(os.path.join(success_dir, result_base),
rh.analyzer_stdout, rh.analyzer_stderr)

rh.postprocess_result(skip_handlers, rs_handler)
rh.postprocess_result(filter_handlers, rs_handler)

# Generated reports will be handled separately at store.

Expand Down Expand Up @@ -487,7 +487,8 @@ def check(check_data):
skiplist handler is None if no skip file was configured.
"""
actions_map, action, analyzer_config, \
output_dir, skip_handlers, rs_handler, quiet_output_on_stdout, \
output_dir, skip_handlers, filter_handlers, \
rs_handler, quiet_output_on_stdout, \
capture_analysis_output, generate_reproducer, analysis_timeout, \
ctu_reanalyze_on_failure, \
output_dirs, statistics_data = check_data
Expand Down Expand Up @@ -605,7 +606,7 @@ def handle_analysis_result(success, zip_file=zip_file):

if success:
handle_success(rh, result_file, result_base,
skip_handlers, rs_handler,
filter_handlers, rs_handler,
capture_analysis_output, success_dir)
elif not generate_reproducer:
handle_failure(source_analyzer, rh,
Expand Down Expand Up @@ -719,7 +720,7 @@ def skip_cpp(compile_actions, skip_handlers):


def start_workers(actions_map, actions, analyzer_config_map,
jobs, output_path, skip_handlers,
jobs, output_path, skip_handlers, filter_handlers,
rs_handler: ReviewStatusHandler, metadata_tool,
quiet_analyze, capture_analysis_output, generate_reproducer,
timeout, ctu_reanalyze_on_failure, statistics_data, manager,
Expand Down Expand Up @@ -785,6 +786,7 @@ def signal_handler(signum, _):
analyzer_config_map.get(build_action.analyzer_type),
output_path,
skip_handlers,
filter_handlers,
rs_handler,
quiet_analyze,
capture_analysis_output,
Expand Down
4 changes: 3 additions & 1 deletion analyzer/codechecker_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def __has_enabled_checker(ch: AnalyzerConfigHandler):
for _, (state, _) in ch.checks().items())


def perform_analysis(args, skip_handlers, rs_handler: ReviewStatusHandler,
def perform_analysis(args, skip_handlers, filter_handlers,
rs_handler: ReviewStatusHandler,
actions, metadata_tool, compile_cmd_count):
"""
Perform static analysis via the given (or if not, all) analyzers,
Expand Down Expand Up @@ -333,6 +334,7 @@ def perform_analysis(args, skip_handlers, rs_handler: ReviewStatusHandler,
config_map, args.jobs,
args.output_path,
skip_handlers,
filter_handlers,
rs_handler,
metadata_tool,
'quiet' in args,
Expand Down
13 changes: 8 additions & 5 deletions analyzer/codechecker_analyzer/analyzers/analyzer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def construct_result_handler(self, buildaction, report_output,
"""
raise NotImplementedError("Subclasses should implement this!")

def analyze(self, analyzer_cmd, res_handler, proc_callback=None):
def analyze(self, analyzer_cmd, res_handler, proc_callback=None, env=None):
"""
Run the analyzer.
"""
Expand All @@ -111,12 +111,17 @@ def analyze(self, analyzer_cmd, res_handler, proc_callback=None):
LOG.debug_analyzer('\n%s',
' '.join([shlex.quote(x) for x in analyzer_cmd]))

if not env:
env = analyzer_context.get_context().get_env_for_bin(
analyzer_cmd[0])

res_handler.analyzer_cmd = analyzer_cmd
try:
ret_code, stdout, stderr \
= SourceAnalyzer.run_proc(analyzer_cmd,
res_handler.buildaction.directory,
proc_callback)
proc_callback,
env)
res_handler.analyzer_returncode = ret_code
res_handler.analyzer_stdout = stdout
res_handler.analyzer_stderr = stderr
Expand All @@ -140,7 +145,7 @@ def post_analyze(self, result_handler):
"""

@staticmethod
def run_proc(command, cwd=None, proc_callback=None):
def run_proc(command, cwd=None, proc_callback=None, env=None):
"""
Just run the given command and return the return code
and the stdout and stderr outputs of the process.
Expand All @@ -156,8 +161,6 @@ def signal_handler(signum, _):

signal.signal(signal.SIGINT, signal_handler)

env = analyzer_context.get_context().get_env_for_bin(command[0])

LOG.debug('\nexecuting:%s\n', command)
LOG.debug('\nENV:\n')
LOG.debug(env)
Expand Down
5 changes: 4 additions & 1 deletion analyzer/codechecker_analyzer/analyzers/analyzer_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
from .clangsa.analyzer import ClangSA
from .cppcheck.analyzer import Cppcheck
from .gcc.analyzer import Gcc
from .infer.analyzer import Infer

LOG = get_logger('analyzer')

supported_analyzers = {ClangSA.ANALYZER_NAME: ClangSA,
ClangTidy.ANALYZER_NAME: ClangTidy,
Cppcheck.ANALYZER_NAME: Cppcheck,
Gcc.ANALYZER_NAME: Gcc}
Gcc.ANALYZER_NAME: Gcc,
Infer.ANALYZER_NAME: Infer
}


def is_ctu_capable():
Expand Down
24 changes: 24 additions & 0 deletions analyzer/codechecker_analyzer/analyzers/infer/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
MIT License

Copyright (c) Facebook, Inc. and its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The following license is valid for descriptions.json file located in the
current directory (codechecker/analyzer/codechecker_analyzer/analyzers/infer/)
Empty file.
Loading

0 comments on commit 0ac3d52

Please sign in to comment.