def validate_args_for_analyze(parser, args, from_build_command): """ Command line parsing is done by the argparse module, but semantic validation still needs to be done. This method is doing it for analyze-build and scan-build commands. :param parser: The command line parser object. :param args: Parsed argument object. :param from_build_command: Boolean value tells is the command suppose to run the analyzer against a build command or a compilation db. :return: No return value, but this call might throw when validation fails. """ if args.help_checkers_verbose: print_checkers(get_checkers(args.clang, args.plugins)) parser.exit(status=0) elif args.help_checkers: print_active_checkers(get_checkers(args.clang, args.plugins)) parser.exit(status=0) elif from_build_command and not args.build: parser.error(message='missing build command') elif not from_build_command and not os.path.exists(args.cdb): parser.error(message='compilation database is missing') # If the user wants CTU mode if not from_build_command and hasattr(args, 'ctu_phases') \ and hasattr(args.ctu_phases, 'dir'): # If CTU analyze_only, the input directory should exist if args.ctu_phases.analyze and not args.ctu_phases.collect \ and not os.path.exists(args.ctu_dir): parser.error(message='missing CTU directory') # Check CTU capability via checking clang-func-mapping if not is_ctu_capable(args.clang, args.func_map_cmd): parser.error(message="""This version of clang does not support CTU functionality or clang-func-mapping command not found.""")
def validate_args_for_analyze(parser, args, from_build_command): """ Command line parsing is done by the argparse module, but semantic validation still needs to be done. This method is doing it for analyze-build and scan-build commands. :param parser: The command line parser object. :param args: Parsed argument object. :param from_build_command: Boolean value tells is the command suppose to run the analyzer against a build command or a compilation db. :return: No return value, but this call might throw when validation fails. """ if args.help_checkers_verbose: print_checkers(get_checkers(args.clang, args.plugins)) parser.exit(status=0) elif args.help_checkers: print_active_checkers(get_checkers(args.clang, args.plugins)) parser.exit(status=0) elif from_build_command and not args.build: parser.error(message='missing build command') elif not from_build_command and not os.path.exists(args.cdb): parser.error(message='compilation database is missing') # If the user wants CTU mode if not from_build_command and hasattr(args, 'ctu_phases') \ and hasattr(args.ctu_phases, 'dir'): # If CTU analyze_only, the input directory should exist if args.ctu_phases.analyze and not args.ctu_phases.collect \ and not os.path.exists(args.ctu_dir): parser.error(message='missing CTU directory') # Check CTU capability via checking clang-extdef-mapping if not is_ctu_capable(args.extdef_map_cmd): parser.error(message="""This version of clang does not support CTU functionality or clang-extdef-mapping command not found.""")
def test_ctu_not_found(self): is_ctu = sut.is_ctu_capable('not-found-clang-func-mapping') self.assertFalse(is_ctu)
def test_ctu_not_found(self): is_ctu = sut.is_ctu_capable('not-found-clang-func-mapping') self.assertFalse(is_ctu)