Skip to content

Commit

Permalink
[analyzer] Create separate tool to collect statistics.
Browse files Browse the repository at this point in the history
- Create a separate analyzer tool which can be used to collect
statistics from the clang analyzer output.
- Add unit tests.
- Rename `statistics_collector.py` to `statistics_manager.py`.
- Use this new tool in CodeChecker.
  • Loading branch information
csordasmarton committed Jul 6, 2020
1 parent dff09da commit febbf77
Show file tree
Hide file tree
Showing 29 changed files with 1,446 additions and 391 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ script:
test_unit \
test_functional \
test_tu_collector \
test_merge_clang_extdef_mappings &&
test_merge_clang_extdef_mappings \
test_statistics_collector &&
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
make -C analyzer test_build_logger
fi
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CC_CLIENT = $(CC_WEB)/client/
CC_ANALYZER = $(CURRENT_DIR)/analyzer

CC_TOOLS = $(CURRENT_DIR)/tools
CC_ANALYZER_TOOLS = $(CC_ANALYZER)/tools

# Root of the repository.
ROOT = $(CURRENT_DIR)
Expand Down Expand Up @@ -79,7 +80,17 @@ package_merge_clang_extdef_mappings: build_merge_clang_extdef_mappings package_d
cd $(CC_BUILD_DIR) && \
ln -sf ../lib/python3/codechecker_merge_clang_extdef_mappings/cli.py bin/merge-clang-extdef-mappings

package: package_dir_structure set_git_commit_template package_plist_to_html package_tu_collector package_report_converter package_report_hash package_merge_clang_extdef_mappings
build_statistics_collector:
$(MAKE) -C $(CC_ANALYZER_TOOLS)/statistics_collector build

package_statistics_collector: build_statistics_collector package_dir_structure
# Copy statistics-collector files.
cp -r $(CC_ANALYZER_TOOLS)/statistics_collector/build/statistics_collector/codechecker_statistics_collector $(CC_BUILD_LIB_DIR) && \
chmod u+x $(CC_BUILD_LIB_DIR)/codechecker_statistics_collector/cli.py && \
cd $(CC_BUILD_DIR) && \
ln -sf ../lib/python3/codechecker_statistics_collector/cli.py bin/post-process-stats

package: package_dir_structure set_git_commit_template package_plist_to_html package_tu_collector package_report_converter package_report_hash package_merge_clang_extdef_mappings package_statistics_collector
BUILD_DIR=$(BUILD_DIR) BUILD_LOGGER_64_BIT_ONLY=$(BUILD_LOGGER_64_BIT_ONLY) $(MAKE) -C $(CC_ANALYZER) package_analyzer
BUILD_DIR=$(BUILD_DIR) $(MAKE) -C $(CC_WEB) package_web

Expand Down Expand Up @@ -163,7 +174,7 @@ clean_venv_dev:

clean: clean_package clean_vendor

clean_package: clean_plist_to_html clean_tu_collector clean_report_converter clean_report_hash
clean_package: clean_plist_to_html clean_tu_collector clean_report_converter clean_report_hash clean_statistics_collector
rm -rf $(BUILD_DIR)
find . -name "*.pyc" -delete

Expand All @@ -182,6 +193,9 @@ clean_report_converter:
clean_report_hash:
$(MAKE) -C $(CC_TOOLS)/codechecker_report_hash clean

clean_statistics_collector:
$(MAKE) -C $(CC_ANALYZER_TOOLS)/statistics_collector clean

clean_travis:
# Clean CodeChecker config files stored in the users home directory.
rm -rf ~/.codechecker*
Expand Down
12 changes: 11 additions & 1 deletion analyzer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,22 @@ package_merge_clang_extdef_mappings: build_merge_clang_extdef_mappings package_d
cd $(CC_BUILD_DIR) && \
ln -sf ../lib/python3/codechecker_merge_clang_extdef_mappings/cli.py bin/merge-clang-extdef-mappings

build_statistics_collector:
$(MAKE) -C $(CC_ANALYZER_TOOLS)/statistics_collector build

package_statistics_collector: build_statistics_collector package_dir_structure
# Copy statistics-collector files.
cp -r tools/statistics_collector/build/statistics_collector/codechecker_statistics_collector $(CC_BUILD_LIB_DIR) && \
chmod u+x $(CC_BUILD_LIB_DIR)/codechecker_statistics_collector/cli.py && \
cd $(CC_BUILD_DIR) && \
ln -sf ../lib/python3/codechecker_statistics_collector/cli.py bin/post-process-stats

# This target should be used from the top level Makefile to build the package
# together with the web part. This way we will not build plist-to-html
# multiple times.
package_analyzer: package_dir_structure

package: package_plist_to_html package_tu_collector package_analyzer package_merge_clang_extdef_mappings
package: package_plist_to_html package_tu_collector package_analyzer package_merge_clang_extdef_mappings package_statistics_collector
# Copy libraries.
cp -r $(ROOT)/codechecker_common $(CC_BUILD_LIB_DIR) && \
cp -r $(CURRENT_DIR)/codechecker_analyzer $(CC_BUILD_LIB_DIR)
Expand Down
4 changes: 3 additions & 1 deletion analyzer/codechecker_analyzer/analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
from codechecker_common import plist_parser
from codechecker_common.logger import get_logger

from statistics_collector.collectors.special_return_value import \
SpecialReturnValueCollector

from . import gcc_toolchain

from .analyzers import analyzer_types
from .analyzers.config_handler import CheckerState
from .analyzers.clangsa.analyzer import ClangSA
from .analyzers.clangsa.statistics_collector import SpecialReturnValueCollector

LOG = get_logger('analyzer')

Expand Down
7 changes: 4 additions & 3 deletions analyzer/codechecker_analyzer/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@

from codechecker_common.logger import get_logger

from statistics_collector.collectors.special_return_value import \
SpecialReturnValueCollector
from statistics_collector.collectors.return_value import ReturnValueCollector

from . import analysis_manager, pre_analysis_manager, env, checkers
from .analyzers import analyzer_types
from .analyzers.config_handler import CheckerState
from .analyzers.clangsa.analyzer import ClangSA
from .analyzers.clangsa.statistics_collector import \
SpecialReturnValueCollector
from .analyzers.clangsa.statistics_collector import ReturnValueCollector


LOG = get_logger('analyzer')
Expand Down
Loading

0 comments on commit febbf77

Please sign in to comment.