Skip to content

Commit 9d49e5c

Browse files
committed
Make mangled_names.test and update_cc_test_checks.py work with Python 2.
Differential Revision: https://reviews.llvm.org/D71565
1 parent 7ab9acd commit 9d49e5c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

llvm/test/tools/UpdateTestChecks/lit.local.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ except ImportError:
1010
from pipes import quote as shell_quote
1111

1212

13-
def add_update_script_substition(name, python_exe=config.python_executable,
14-
extra_args=''):
13+
def add_update_script_substition(name, extra_args=''):
1514
script_path = os.path.join(config.llvm_src_root, 'utils', name + '.py')
1615
assert os.path.isfile(script_path)
1716
config.substitutions.append(
18-
('%' + name, "'%s' %s %s" % (python_exe, script_path, extra_args)))
17+
('%' + name, "'%s' %s %s" % (
18+
config.python_executable, script_path, extra_args)))
1919

2020

2121
config.test_format = lit.formats.ShTest(execute_external=False)

llvm/utils/update_cc_test_checks.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
22
'''A utility to update LLVM IR CHECK lines in C/C++ FileCheck test files.
33
44
Example RUN lines in .c/.cc test files:
@@ -12,6 +12,8 @@
1212
% utils/update_cc_test_checks.py --clang=release/bin/clang /tmp/c/a.cc
1313
'''
1414

15+
from __future__ import print_function
16+
1517
import argparse
1618
import collections
1719
import distutils.spawn
@@ -37,18 +39,21 @@
3739
def get_line2spell_and_mangled(args, clang_args):
3840
ret = {}
3941
# Use clang's JSON AST dump to get the mangled name
40-
json_dump_args = [args.clang, *clang_args, '-fsyntax-only', '-o', '-']
42+
json_dump_args = [args.clang] + clang_args + ['-fsyntax-only', '-o', '-']
4143
if '-cc1' not in json_dump_args:
4244
# For tests that invoke %clang instead if %clang_cc1 we have to use
4345
# -Xclang -ast-dump=json instead:
4446
json_dump_args.append('-Xclang')
4547
json_dump_args.append('-ast-dump=json')
4648
common.debug('Running', ' '.join(json_dump_args))
47-
status = subprocess.run(json_dump_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
48-
if status.returncode != 0:
49+
50+
popen = subprocess.Popen(json_dump_args, stdout=subprocess.PIPE,
51+
stderr=subprocess.PIPE, universal_newlines=True)
52+
stdout, stderr = popen.communicate()
53+
if popen.returncode != 0:
4954
sys.stderr.write('Failed to run ' + ' '.join(json_dump_args) + '\n')
50-
sys.stderr.write(status.stderr.decode())
51-
sys.stderr.write(status.stdout.decode())
55+
sys.stderr.write(stderr)
56+
sys.stderr.write(stdout)
5257
sys.exit(2)
5358

5459
# Parse the clang JSON and add all children of type FunctionDecl.
@@ -75,7 +80,7 @@ def parse_clang_ast_json(node):
7580
mangled = node.get('mangledName', spell)
7681
ret[int(line)-1] = (spell, mangled)
7782

78-
ast = json.loads(status.stdout.decode())
83+
ast = json.loads(stdout)
7984
if ast['kind'] != 'TranslationUnitDecl':
8085
common.error('Clang AST dump JSON format changed?')
8186
sys.exit(2)

0 commit comments

Comments
 (0)