diff options
Diffstat (limited to 'tools/scan-build-py/libscanbuild/analyze.py')
-rw-r--r-- | tools/scan-build-py/libscanbuild/analyze.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/tools/scan-build-py/libscanbuild/analyze.py b/tools/scan-build-py/libscanbuild/analyze.py index 9b00d04fc0..0ed0aef838 100644 --- a/tools/scan-build-py/libscanbuild/analyze.py +++ b/tools/scan-build-py/libscanbuild/analyze.py @@ -25,8 +25,7 @@ from libscanbuild.runner import run from libscanbuild.intercept import capture from libscanbuild.report import report_directory, document from libscanbuild.clang import get_checkers -from libscanbuild.runner import action_check -from libscanbuild.command import classify_parameters, classify_source +from libscanbuild.compilation import split_command __all__ = ['analyze_build_main', 'analyze_build_wrapper'] @@ -107,7 +106,7 @@ def run_analyzer(args, output_dir): 'output_format': args.output_format, 'output_failures': args.output_failures, 'direct_args': analyzer_params(args), - 'force_analyze_debug_code' : args.force_analyze_debug_code + 'force_debug': args.force_debug } logging.debug('run analyzer against compilation database') @@ -140,8 +139,7 @@ def setup_environment(args, destination, bin_dir): 'ANALYZE_BUILD_REPORT_FORMAT': args.output_format, 'ANALYZE_BUILD_REPORT_FAILURES': 'yes' if args.output_failures else '', 'ANALYZE_BUILD_PARAMETERS': ' '.join(analyzer_params(args)), - 'ANALYZE_BUILD_FORCE_ANALYZE_DEBUG_CODE' - : 'yes' if args.force_analyze_debug_code else '' + 'ANALYZE_BUILD_FORCE_DEBUG': 'yes' if args.force_debug else '' }) return environment @@ -163,32 +161,34 @@ def analyze_build_wrapper(cplusplus): return result # ... and run the analyzer if all went well. try: + # check is it a compilation + compilation = split_command(sys.argv) + if compilation is None: + return result # collect the needed parameters from environment, crash when missing - consts = { + parameters = { 'clang': os.getenv('ANALYZE_BUILD_CLANG'), 'output_dir': os.getenv('ANALYZE_BUILD_REPORT_DIR'), 'output_format': os.getenv('ANALYZE_BUILD_REPORT_FORMAT'), 'output_failures': os.getenv('ANALYZE_BUILD_REPORT_FAILURES'), 'direct_args': os.getenv('ANALYZE_BUILD_PARAMETERS', '').split(' '), - 'force_analyze_debug_code': - os.getenv('ANALYZE_BUILD_FORCE_ANALYZE_DEBUG_CODE'), + 'force_debug': os.getenv('ANALYZE_BUILD_FORCE_DEBUG'), 'directory': os.getcwd(), + 'command': [sys.argv[0], '-c'] + compilation.flags } - # get relevant parameters from command line arguments - args = classify_parameters(sys.argv) - filenames = args.pop('files', []) - for filename in (name for name in filenames if classify_source(name)): - parameters = dict(args, file=filename, **consts) + # call static analyzer against the compilation + for source in compilation.files: + parameters.update({'file': source}) logging.debug('analyzer parameters %s', parameters) - current = action_check(parameters) + current = run(parameters) # display error message from the static analyzer if current is not None: for line in current['error_output']: logging.info(line.rstrip()) except Exception: logging.exception("run analyzer inside compiler wrapper failed.") - return 0 + return result def analyzer_params(args): @@ -208,8 +208,8 @@ def analyzer_params(args): if args.store_model: result.append('-analyzer-store={0}'.format(args.store_model)) if args.constraints_model: - result.append( - '-analyzer-constraints={0}'.format(args.constraints_model)) + result.append('-analyzer-constraints={0}'.format( + args.constraints_model)) if args.internal_stats: result.append('-analyzer-stats') if args.analyze_headers: @@ -457,11 +457,10 @@ def create_parser(from_build_command): the compilation database.""") advanced.add_argument( '--force-analyze-debug-code', - dest='force_analyze_debug_code', + dest='force_debug', action='store_true', help="""Tells analyzer to enable assertions in code even if they were - disabled during compilation, enabling more precise - results.""") + disabled during compilation, enabling more precise results.""") plugins = parser.add_argument_group('checker options') plugins.add_argument( |