summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerge Guelton <sguelton@redhat.com>2019-03-21 07:19:09 +0000
committerSerge Guelton <sguelton@redhat.com>2019-03-21 07:19:09 +0000
commit32cffcf1aba9e5ac3315556b852e9c8ea6da64e7 (patch)
treee8bf3aae50d6306224b89993d01030b2e8fae90c
parent8de7bc0bff05a5d5bc5d8849687993234f5e0ea9 (diff)
downloadbcm5719-llvm-32cffcf1aba9e5ac3315556b852e9c8ea6da64e7.tar.gz
bcm5719-llvm-32cffcf1aba9e5ac3315556b852e9c8ea6da64e7.zip
Use list comprehension instead of map/filter to prepare Python2/3 compat
Differential Revision: https://reviews.llvm.org/D59579 llvm-svn: 356647
-rw-r--r--lldb/packages/Python/lldbsuite/test/dotest.py3
-rwxr-xr-xlldb/scripts/analyze-project-deps.py4
-rw-r--r--lldb/scripts/swig_bot_lib/local.py6
-rw-r--r--lldb/utils/lui/lldbutil.py16
-rw-r--r--lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py4
5 files changed, 15 insertions, 18 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index c6cae1b3406..b406def22f7 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -524,8 +524,7 @@ def parseOptionsAndInitTestdirs():
# Gather all the dirs passed on the command line.
if len(args.args) > 0:
- configuration.testdirs = list(
- map(lambda x: os.path.realpath(os.path.abspath(x)), args.args))
+ configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x in args.args]
# Shut off multiprocessing mode when test directories are specified.
configuration.no_multiprocess_test_runner = True
diff --git a/lldb/scripts/analyze-project-deps.py b/lldb/scripts/analyze-project-deps.py
index b7f6e6803d0..c6e3263a2f2 100755
--- a/lldb/scripts/analyze-project-deps.py
+++ b/lldb/scripts/analyze-project-deps.py
@@ -65,7 +65,7 @@ def scan_deps(this_dir, file):
for (base, dirs, files) in os.walk(inc_dir):
dir = os.path.basename(base)
relative = os.path.relpath(base, inc_dir)
- inc_files = filter(lambda x : os.path.splitext(x)[1] in [".h"], files)
+ inc_files = [x for x in files if os.path.splitext(x)[1] in [".h"]]
relative = relative.replace("\\", "/")
for inc in inc_files:
inc_path = os.path.join(base, inc)
@@ -74,7 +74,7 @@ for (base, dirs, files) in os.walk(inc_dir):
for (base, dirs, files) in os.walk(src_dir):
dir = os.path.basename(base)
relative = os.path.relpath(base, src_dir)
- src_files = filter(lambda x : os.path.splitext(x)[1] in [".cpp", ".h", ".mm"], files)
+ src_files = [x for x in files if os.path.splitext(x)[1] in [".cpp", ".h", ".mm"]]
norm_base_path = os.path.normpath(os.path.join("lldb", relative))
norm_base_path = norm_base_path.replace("\\", "/")
for src in src_files:
diff --git a/lldb/scripts/swig_bot_lib/local.py b/lldb/scripts/swig_bot_lib/local.py
index b26ea2f53ea..ea073af8257 100644
--- a/lldb/scripts/swig_bot_lib/local.py
+++ b/lldb/scripts/swig_bot_lib/local.py
@@ -54,10 +54,8 @@ def pack_archive(bytes_io, src_root, filters):
full_path = os.path.normpath(os.path.join(src_root, subfolder))
candidates = [os.path.normpath(os.path.join(full_path, f))
for f in os.listdir(full_path)]
- actual = filter(
- lambda f: os.path.isfile(f) and os.path.splitext(f)[1] == ext,
- candidates)
- return (subfolder, map(lambda f: os.path.basename(f), actual))
+ actual = [f for f in candidates if os.path.isfile(f) and os.path.splitext(f)[1] == ext]
+ return (subfolder, [os.path.basename(f) for f in actual])
archive_entries = map(filter_func, filters)
else:
for (root, dirs, files) in os.walk(src_root):
diff --git a/lldb/utils/lui/lldbutil.py b/lldb/utils/lui/lldbutil.py
index cd608ba48e8..80d581c766d 100644
--- a/lldb/utils/lui/lldbutil.py
+++ b/lldb/utils/lui/lldbutil.py
@@ -84,7 +84,7 @@ def int_to_bytearray(val, bytesize):
return None
packed = struct.pack(fmt, val)
- return bytearray(map(ord, packed))
+ return bytearray(ord(x) for x in packed)
def bytearray_to_int(bytes, bytesize):
@@ -706,7 +706,7 @@ def get_function_names(thread):
def GetFuncName(i):
return thread.GetFrameAtIndex(i).GetFunctionName()
- return map(GetFuncName, range(thread.GetNumFrames()))
+ return [GetFuncName(i) for i in range(thread.GetNumFrames())]
def get_symbol_names(thread):
@@ -716,7 +716,7 @@ def get_symbol_names(thread):
def GetSymbol(i):
return thread.GetFrameAtIndex(i).GetSymbol().GetName()
- return map(GetSymbol, range(thread.GetNumFrames()))
+ return [GetSymbol(i) for i in range(thread.GetNumFrames())]
def get_pc_addresses(thread):
@@ -726,7 +726,7 @@ def get_pc_addresses(thread):
def GetPCAddress(i):
return thread.GetFrameAtIndex(i).GetPCAddress()
- return map(GetPCAddress, range(thread.GetNumFrames()))
+ return [GetPCAddress(i) for i in range(thread.GetNumFrames())]
def get_filenames(thread):
@@ -737,7 +737,7 @@ def get_filenames(thread):
return thread.GetFrameAtIndex(
i).GetLineEntry().GetFileSpec().GetFilename()
- return map(GetFilename, range(thread.GetNumFrames()))
+ return [GetFilename(i) for i in range(thread.GetNumFrames())]
def get_line_numbers(thread):
@@ -747,7 +747,7 @@ def get_line_numbers(thread):
def GetLineNumber(i):
return thread.GetFrameAtIndex(i).GetLineEntry().GetLine()
- return map(GetLineNumber, range(thread.GetNumFrames()))
+ return [GetLineNumber(i) for i in range(thread.GetNumFrames())]
def get_module_names(thread):
@@ -758,7 +758,7 @@ def get_module_names(thread):
return thread.GetFrameAtIndex(
i).GetModule().GetFileSpec().GetFilename()
- return map(GetModuleName, range(thread.GetNumFrames()))
+ return [GetModuleName(i) for i in range(thread.GetNumFrames())]
def get_stack_frames(thread):
@@ -768,7 +768,7 @@ def get_stack_frames(thread):
def GetStackFrame(i):
return thread.GetFrameAtIndex(i)
- return map(GetStackFrame, range(thread.GetNumFrames()))
+ return [GetStackFrame(i) for i in range(thread.GetNumFrames())]
def print_stacktrace(thread, string_buffer=False):
diff --git a/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py b/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py
index ed54633a3ea..b36769f5a57 100644
--- a/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py
+++ b/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py
@@ -102,8 +102,8 @@ class LLDBController(object):
pass
if result.GetSize() > 0:
- results = filter(None, [result.GetStringAtIndex(x)
- for x in range(result.GetSize())])
+ results = [_f for _f in [result.GetStringAtIndex(x)
+ for x in range(result.GetSize())] if _f]
return results
else:
return []
OpenPOWER on IntegriCloud