def main(): parser = argparse.ArgumentParser() parser.add_argument( '--mode', choices=['clang', 'cl'], required=True, help='Specifies the compiler argument convention to use.') parser.add_argument('args', nargs=argparse.REMAINDER) parsed_args = parser.parse_args() prefix = '-Xclang' if parsed_args.mode == 'cl' else '-Xanalyzer' cmd = parsed_args.args + analyzer_enable_flags + \ interleave_args(analyzer_option_flags, prefix) returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(cmd)) sys.stderr.write(stderr) if returncode != 0: sys.stderr.write( """WARNING! The Clang static analyzer exited with error code %d. Please share the error details in crbug.com/695243 if this looks like a new regression.\n""" % (returncode)) returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(parsed_args.args)) sys.stderr.write(stderr) return returncode
def main(): parser = argparse.ArgumentParser() parser.add_argument('--mode', choices=['clang', 'cl'], required=True, help='Specifies the compiler argument convention to use.') parser.add_argument('args', nargs=argparse.REMAINDER) parsed_args = parser.parse_args() prefix = '-Xclang' if parsed_args.mode == 'cl' else '-Xanalyzer' cmd = parsed_args.args + analyzer_enable_flags + \ interleave_args(analyzer_option_flags, prefix) returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(cmd)) sys.stderr.write(stderr.decode()) returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(parsed_args.args)) sys.stderr.write(stderr.decode()) return returncode
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--clang-cc-path', help='Path to the clang compiler.', metavar='PATH') parser.add_argument('--clang-cxx-path', help='Path to the clang++ compiler', metavar='PATH') parser.add_argument('--analyzer', help='Path to the language-specific Clang analysis tool.', required=True, metavar='PATH') args, compile_args = parser.parse_known_args() # Check that only one of --clang-cc-path or --clang-cxx-path are set. assert ((args.clang_cc_path != None) != (args.clang_cxx_path != None)) is_cxx = args.clang_cxx_path != None env = os.environ env['CCC_ANALYZER_FORCE_ANALYZE_DEBUG_CODE'] = '0' env['CCC_ANALYZER_OUTPUT_FORMAT'] = 'text' clang_path = args.clang_cxx_path or args.clang_cc_path if is_cxx: env['CCC_CXX'] = clang_path env['CLANG_CXX'] = clang_path else: env['CCC_CC'] = clang_path env['CLANG'] = clang_path # TODO(kmarshall): Place the summarized output in a useful directory. temp_dir = tempfile.mkdtemp() try: env['CCC_ANALYZER_HTML'] = temp_dir returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun([args.analyzer] + compile_args), env) sys.stderr.write(stderr) return returncode finally: shutil.rmtree(temp_dir)
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--resource-whitelist', help='Generate a resource whitelist for this target.', metavar='PATH') parser.add_argument('command', nargs=argparse.REMAINDER, help='Compilation command') args = parser.parse_args() returncode, stderr = wrapper_utils.CaptureCommandStderr( wrapper_utils.CommandToRun(args.command)) used_resources = wrapper_utils.ExtractResourceIdsFromPragmaWarnings(stderr) sys.stderr.write(stderr) if args.resource_whitelist: with open(args.resource_whitelist, 'w') as f: if used_resources: f.write('\n'.join( str(resource) for resource in used_resources)) f.write('\n') return returncode