diff options
author | Laszlo Nagy <rizsotto.mailinglist@gmail.com> | 2016-04-19 12:03:03 +0000 |
---|---|---|
committer | Laszlo Nagy <rizsotto.mailinglist@gmail.com> | 2016-04-19 12:03:03 +0000 |
commit | 8bd63e5518f12352387e0e4a183dc331b657c4d1 (patch) | |
tree | 92f1d02a11d6815affa4160032773b80cd0bd376 /clang/tools/scan-build-py/libscanbuild/analyze.py | |
parent | 79b25d5ea4fd31267a163a9862f153d20e4fdbfe (diff) | |
download | bcm5719-llvm-8bd63e5518f12352387e0e4a183dc331b657c4d1.tar.gz bcm5719-llvm-8bd63e5518f12352387e0e4a183dc331b657c4d1.zip |
D17487: [analyzer][scan-build-py] flag filter modification for compilation database creation
llvm-svn: 266726
Diffstat (limited to 'clang/tools/scan-build-py/libscanbuild/analyze.py')
-rw-r--r-- | clang/tools/scan-build-py/libscanbuild/analyze.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/clang/tools/scan-build-py/libscanbuild/analyze.py b/clang/tools/scan-build-py/libscanbuild/analyze.py index 9b00d04fc0f..0ed0aef8387 100644 --- a/clang/tools/scan-build-py/libscanbuild/analyze.py +++ b/clang/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( |