summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-01-02 13:44:54 -0500
committerNico Weber <thakis@chromium.org>2020-01-02 13:45:39 -0500
commit9d49e5c0876f7cf75ce0b5d8b3c8473300eb096a (patch)
treeeaa0744151aa35d7dede0614bf8512a814638d73
parent7ab9acd8f414161b784b61a1633a7c241b82be85 (diff)
downloadbcm5719-llvm-9d49e5c0876f7cf75ce0b5d8b3c8473300eb096a.tar.gz
bcm5719-llvm-9d49e5c0876f7cf75ce0b5d8b3c8473300eb096a.zip
Make mangled_names.test and update_cc_test_checks.py work with Python 2.
Differential Revision: https://reviews.llvm.org/D71565
-rw-r--r--llvm/test/tools/UpdateTestChecks/lit.local.cfg6
-rwxr-xr-xllvm/utils/update_cc_test_checks.py19
2 files changed, 15 insertions, 10 deletions
diff --git a/llvm/test/tools/UpdateTestChecks/lit.local.cfg b/llvm/test/tools/UpdateTestChecks/lit.local.cfg
index 879bfc51c5e..c72935f0a77 100644
--- a/llvm/test/tools/UpdateTestChecks/lit.local.cfg
+++ b/llvm/test/tools/UpdateTestChecks/lit.local.cfg
@@ -10,12 +10,12 @@ except ImportError:
from pipes import quote as shell_quote
-def add_update_script_substition(name, python_exe=config.python_executable,
- extra_args=''):
+def add_update_script_substition(name, extra_args=''):
script_path = os.path.join(config.llvm_src_root, 'utils', name + '.py')
assert os.path.isfile(script_path)
config.substitutions.append(
- ('%' + name, "'%s' %s %s" % (python_exe, script_path, extra_args)))
+ ('%' + name, "'%s' %s %s" % (
+ config.python_executable, script_path, extra_args)))
config.test_format = lit.formats.ShTest(execute_external=False)
diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py
index e251ff0b8f5..98e8e3774fc 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
'''A utility to update LLVM IR CHECK lines in C/C++ FileCheck test files.
Example RUN lines in .c/.cc test files:
@@ -12,6 +12,8 @@ Usage:
% utils/update_cc_test_checks.py --clang=release/bin/clang /tmp/c/a.cc
'''
+from __future__ import print_function
+
import argparse
import collections
import distutils.spawn
@@ -37,18 +39,21 @@ SUBST = {
def get_line2spell_and_mangled(args, clang_args):
ret = {}
# Use clang's JSON AST dump to get the mangled name
- json_dump_args = [args.clang, *clang_args, '-fsyntax-only', '-o', '-']
+ json_dump_args = [args.clang] + clang_args + ['-fsyntax-only', '-o', '-']
if '-cc1' not in json_dump_args:
# For tests that invoke %clang instead if %clang_cc1 we have to use
# -Xclang -ast-dump=json instead:
json_dump_args.append('-Xclang')
json_dump_args.append('-ast-dump=json')
common.debug('Running', ' '.join(json_dump_args))
- status = subprocess.run(json_dump_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- if status.returncode != 0:
+
+ popen = subprocess.Popen(json_dump_args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, universal_newlines=True)
+ stdout, stderr = popen.communicate()
+ if popen.returncode != 0:
sys.stderr.write('Failed to run ' + ' '.join(json_dump_args) + '\n')
- sys.stderr.write(status.stderr.decode())
- sys.stderr.write(status.stdout.decode())
+ sys.stderr.write(stderr)
+ sys.stderr.write(stdout)
sys.exit(2)
# Parse the clang JSON and add all children of type FunctionDecl.
@@ -75,7 +80,7 @@ def get_line2spell_and_mangled(args, clang_args):
mangled = node.get('mangledName', spell)
ret[int(line)-1] = (spell, mangled)
- ast = json.loads(status.stdout.decode())
+ ast = json.loads(stdout)
if ast['kind'] != 'TranslationUnitDecl':
common.error('Clang AST dump JSON format changed?')
sys.exit(2)
OpenPOWER on IntegriCloud