diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py @@ -22,6 +22,8 @@ http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html """ +from __future__ import print_function + import argparse import json import multiprocessing @@ -39,7 +41,7 @@ result = './' while not os.path.isfile(os.path.join(result, path)): if os.path.realpath(result) == '/': - print 'Error: could not find compilation database.' + print('Error: could not find compilation database.', file=sys.stderr) sys.exit(1) result += '../' return os.path.realpath(result) @@ -49,7 +51,7 @@ """Merge all symbol files (yaml) in a given directory into a single file.""" invocation = [args.binary, '-merge-dir='+directory, args.saving_path] subprocess.call(invocation) - print 'Merge is finished. Saving results in ' + args.saving_path + print('Merge is finished. Saving results in ' + args.saving_path) def run_find_all_symbols(args, tmpdir, build_path, queue): @@ -118,7 +120,7 @@ except KeyboardInterrupt: # This is a sad hack. Unfortunately subprocess goes # bonkers with ctrl-c and we start forking merrily. - print '\nCtrl-C detected, goodbye.' + print('\nCtrl-C detected, goodbye.') os.kill(0, 9) diff --git a/clang-tools-extra/clangd/include-mapping/gen_std.py b/clang-tools-extra/clangd/include-mapping/gen_std.py --- a/clang-tools-extra/clangd/include-mapping/gen_std.py +++ b/clang-tools-extra/clangd/include-mapping/gen_std.py @@ -99,12 +99,12 @@ index_page_path = os.path.join(page_root, "index.html") cppreference_modified_date = datetime.datetime.fromtimestamp( os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d') - print CODE_PREFIX % (args.language.upper(), cppreference_modified_date) + print(CODE_PREFIX % (args.language.upper(), cppreference_modified_date)) for symbol in symbols: if len(symbol.headers) == 1: # SYMBOL(unqualified_name, namespace, header) - print "SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace, - symbol.headers[0]) + print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace, + symbol.headers[0])) elif len(symbol.headers) == 0: sys.stderr.write("No header found for symbol %s\n" % symbol.name) else: diff --git a/compiler-rt/lib/dfsan/scripts/build-libc-list.py b/compiler-rt/lib/dfsan/scripts/build-libc-list.py --- a/compiler-rt/lib/dfsan/scripts/build-libc-list.py +++ b/compiler-rt/lib/dfsan/scripts/build-libc-list.py @@ -11,6 +11,8 @@ # uninstrumented, thus allowing the instrumentation pass to treat calls to those # functions correctly. +from __future__ import print_function + import os import subprocess import sys @@ -86,10 +88,10 @@ if os.path.exists(l): functions += defined_function_list(l) else: - print >> sys.stderr, 'warning: library %s not found' % l + print('warning: library %s not found' % l, file=sys.stderr) functions = list(set(functions)) functions.sort() for f in functions: - print 'fun:%s=uninstrumented' % f + print('fun:%s=uninstrumented' % f) diff --git a/compiler-rt/test/sanitizer_common/android_commands/android_common.py b/compiler-rt/test/sanitizer_common/android_commands/android_common.py --- a/compiler-rt/test/sanitizer_common/android_commands/android_common.py +++ b/compiler-rt/test/sanitizer_common/android_commands/android_common.py @@ -15,7 +15,7 @@ def adb(args, attempts = 1): if verbose: - print args + print(args) tmpname = tempfile.mktemp() out = open(tmpname, 'w') ret = 255 @@ -25,11 +25,11 @@ if attempts != 0: ret = 5 if ret != 0: - print "adb command failed", args - print tmpname + print("adb command failed", args) + print(tmpname) out.close() out = open(tmpname, 'r') - print out.read() + print(out.read()) out.close() os.unlink(tmpname) return ret diff --git a/compiler-rt/test/sanitizer_common/android_commands/android_compile.py b/compiler-rt/test/sanitizer_common/android_commands/android_compile.py --- a/compiler-rt/test/sanitizer_common/android_commands/android_compile.py +++ b/compiler-rt/test/sanitizer_common/android_commands/android_compile.py @@ -21,7 +21,7 @@ output = args.pop(0) if output == None: - print "No output file name!" + print('No output file name!') sys.exit(1) ret = subprocess.call(sys.argv[1:]) diff --git a/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py b/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py --- a/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py +++ b/compiler-rt/test/sanitizer_common/ios_commands/iossim_compile.py @@ -20,7 +20,7 @@ output = args.pop(0) if output == None: - print "No output file name!" + print('No output file name!') sys.exit(1) ret = subprocess.call(sys.argv[1:]) diff --git a/debuginfo-tests/llgdb-tests/llgdb.py b/debuginfo-tests/llgdb-tests/llgdb.py --- a/debuginfo-tests/llgdb-tests/llgdb.py +++ b/debuginfo-tests/llgdb-tests/llgdb.py @@ -34,11 +34,11 @@ except ImportError: pass else: - print 'imported lldb from: "%s"' % (lldb_python_dir) + print('imported lldb from: "%s"' % (lldb_python_dir)) success = True break if not success: - print "error: couldn't locate the 'lldb' module, please set PYTHONPATH correctly" + print("error: couldn't locate the 'lldb' module, please set PYTHONPATH correctly") sys.exit(1) # ---------------------------------------------------------------------- diff --git a/lldb/utils/lui/lldbutil.py b/lldb/utils/lui/lldbutil.py --- a/lldb/utils/lui/lldbutil.py +++ b/lldb/utils/lui/lldbutil.py @@ -919,7 +919,7 @@ from lldbutil import get_GPRs regs = get_GPRs(frame) for reg in regs: - print "%s => %s" % (reg.GetName(), reg.GetValue()) + print("%s => %s" % (reg.GetName(), reg.GetValue())) ... """ return get_registers(frame, "general purpose") @@ -933,7 +933,7 @@ from lldbutil import get_FPRs regs = get_FPRs(frame) for reg in regs: - print "%s => %s" % (reg.GetName(), reg.GetValue()) + print("%s => %s" % (reg.GetName(), reg.GetValue())) ... """ return get_registers(frame, "floating point") @@ -947,7 +947,7 @@ from lldbutil import get_ESRs regs = get_ESRs(frame) for reg in regs: - print "%s => %s" % (reg.GetName(), reg.GetValue()) + print("%s => %s" % (reg.GetName(), reg.GetValue())) ... """ return get_registers(frame, "exception state") diff --git a/llvm/bindings/python/llvm/object.py b/llvm/bindings/python/llvm/object.py --- a/llvm/bindings/python/llvm/object.py +++ b/llvm/bindings/python/llvm/object.py @@ -57,22 +57,22 @@ # This is NOT OK. You perform a lookup after the object has expired. symbols = list(obj.get_symbols()) for symbol in symbols: - print symbol.name # This raises because the object has expired. + print(symbol.name) # This raises because the object has expired. # In this example, we mix a working and failing scenario. symbols = [] for symbol in obj.get_symbols(): symbols.append(symbol) - print symbol.name + print(symbol.name) for symbol in symbols: - print symbol.name # OK + print(symbol.name) # OK print symbol.address # NOT OK. We didn't look up this property before. # Cache everything up front. symbols = list(obj.get_symbols(cache=True)) for symbol in symbols: - print symbol.name # OK + print(symbol.name) # OK """ diff --git a/openmp/runtime/tools/summarizeStats.py b/openmp/runtime/tools/summarizeStats.py --- a/openmp/runtime/tools/summarizeStats.py +++ b/openmp/runtime/tools/summarizeStats.py @@ -143,7 +143,7 @@ res["counters"] = readCounters(f) return res except (OSError, IOError): - print "Cannot open " + fname + print("Cannot open " + fname) return None def usefulValues(l): @@ -235,7 +235,7 @@ compKeys[key] = data[key] else: nonCompKeys[key] = data[key] - print "comp keys:", compKeys, "\n\n non comp keys:", nonCompKeys + print("comp keys:", compKeys, "\n\n non comp keys:", nonCompKeys) return [compKeys, nonCompKeys] def drawMainPie(data, filebase, colors): @@ -301,7 +301,7 @@ """radar Charts finish here""" plt.savefig(filebase+"_"+s+"_"+chartType, bbox_inches='tight') elif s == 'timers': - print "overheads in "+filebase + print("overheads in " + filebase) numThreads = tmp[s]['SampleCount']['Total_OMP_parallel'] for key in data.keys(): if key[0:5] == 'Total': diff --git a/polly/utils/jscop2cloog.py b/polly/utils/jscop2cloog.py --- a/polly/utils/jscop2cloog.py +++ b/polly/utils/jscop2cloog.py @@ -50,7 +50,7 @@ context = scop['context'] domains = getDomains(scop) schedules = getSchedules(scop) - print template % (context, domains, schedules) + print(template % (context, domains, schedules)) def __main__(): description = 'Translate JSCoP into iscc input' diff --git a/polly/utils/pyscop/jscop2iscc.py b/polly/utils/pyscop/jscop2iscc.py --- a/polly/utils/pyscop/jscop2iscc.py +++ b/polly/utils/pyscop/jscop2iscc.py @@ -1,4 +1,7 @@ #!/usr/bin/env python + +from __future__ import print_function + import argparse, isl, os import json @@ -9,8 +12,8 @@ for statement in scop['statements']: domain = domain.union(isl.USet(statement['domain'])) - print "D :=", - print str(domain) + ";" + print('D :=', end='') + print(str(domain) + ';') def printAccesses(scop): @@ -21,8 +24,8 @@ if access['kind'] == 'read': read = read.union(isl.UMap(access['relation'])) - print "R :=", - print str(read) + ";" + print('R :=', end='') + print(str(read) + ';') write = isl.UMap('{}') @@ -31,8 +34,8 @@ if access['kind'] == 'write': write = write.union(isl.UMap(access['relation'])) - print "W :=", - print str(write) + ";" + print('W :=', end='') + print(str(write) + ';') def printSchedule(scop): @@ -41,8 +44,8 @@ for statement in scop['statements']: schedule = schedule.union(isl.UMap(statement['schedule'])) - print "S :=", - print str(schedule) + ";" + print('S :=', end='') + print(str(schedule) + ';') def __main__(): description = 'Translate JSCoP into iscc input' @@ -58,10 +61,10 @@ printAccesses(scop) printSchedule(scop) - print 'R := R * D;' - print 'W := W * D;' - print 'Dep := (last W before R under S)[0];' - print 'schedule D respecting Dep minimizing Dep;' + print('R := R * D;') + print('W := W * D;') + print('Dep := (last W before R under S)[0];') + print('schedule D respecting Dep minimizing Dep;') __main__()