aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Guelton <sguelton@quarkslab.com>2019-01-04 08:14:28 +0000
committerSerge Guelton <sguelton@quarkslab.com>2019-01-04 08:14:28 +0000
commitb7deeca7743235fba6b2cd4cc2e0250821e0cd33 (patch)
tree849176f289a05d31f27ea5a7a3faf2edbae137b5
parentf7cd127dcba75d524bd480929b22d5489f40649d (diff)
Modernize Python scripts
Use type destructuring instead of explicit indexing. This is preparatory work for python2/3 compatibility. Differential Revision: https://reviews.llvm.org/D55989 git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@350381 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xCompareDebugInfo.py31
-rwxr-xr-xFindMissingLineNo.py4
2 files changed, 14 insertions, 21 deletions
diff --git a/CompareDebugInfo.py b/CompareDebugInfo.py
index be6fa236..7ec2d998 100755
--- a/CompareDebugInfo.py
+++ b/CompareDebugInfo.py
@@ -46,24 +46,23 @@ class BreakPoint:
def __repr__(self):
print self.name
- items = self.values.items()
- for i in range(len(items)):
- print items[i][0]," = ",items[i][1]
+ for k, v in self.values.items():
+ print k, "=", v
return ''
def compare_args(self, other, file):
myitems = self.values.items()
otheritems = other.values.items()
match = False
- for i in range(len(myitems)):
+ for i, my_item in enumerate(my_items):
if i >= len(otheritems):
match = True
- self.missing_args.append(myitems[i][0])
- elif cmp(myitems[i][1], otheritems[i][1]):
+ self.missing_args.append(myitem[0])
+ elif cmp(myitem[1], otheritems[i][1]):
match = True
- self.notmatching_args.append(myitems[i][0])
+ self.notmatching_args.append(myitem[0])
else:
- self.matching_args.append(myitems[i][0])
+ self.matching_args.append(myitem[0])
self.print_list(self.matching_args, " Matching arguments ", file)
self.print_list(self.notmatching_args, " Not Matching arguments ", file)
@@ -108,9 +107,7 @@ f2_items = f2_breakpoints.items()
f = open(LOG_FILE, "w")
f.write("Log output\n")
-for f2bp in range(len(f2_items)):
- id = f2_items[f2bp][0]
- bp = f2_items[f2bp][1]
+for id, bp in f2_items:
bp1 = f1_breakpoints.get(id)
if bp1 is None:
bp.setMissing()
@@ -127,9 +124,7 @@ read_input(NATIVE_OPT_DBG_OUTPUT_FILE, nf2_breakpoints)
nf2_items = nf2_breakpoints.items()
nfl = open(NATIVE_LOG_FILE, "w")
-for nf2bp in range(len(nf2_items)):
- id = nf2_items[nf2bp][0]
- bp = nf2_items[nf2bp][1]
+for id, bp in nf2_items:
bp1 = nf1_breakpoints.get(id)
if bp1 is None:
bp.setMissing()
@@ -141,8 +136,8 @@ f1_arg_count = 0
f1_matching_arg_count = 0
f1_notmatching_arg_count = 0
f1_missing_arg_count = 0
-for idx in range(len(f1_items)):
- bp = f1_items[idx][1]
+for f1_item in f1_items:
+ bp = f1_item[1]
f1_arg_count = f1_arg_count + bp.getArgCount()
f1_matching_arg_count = f1_matching_arg_count + bp.getMatchingArgCount()
f1_notmatching_arg_count = f1_notmatching_arg_count + bp.getNotMatchingArgCount()
@@ -152,8 +147,8 @@ nf1_arg_count = 0
nf1_matching_arg_count = 0
nf1_notmatching_arg_count = 0
nf1_missing_arg_count = 0
-for idx in range(len(nf1_items)):
- bp = nf1_items[idx][1]
+for nf1_item in nf1_items:
+ bp = nf1_item[1]
nf1_arg_count = nf1_arg_count + bp.getArgCount()
nf1_matching_arg_count = nf1_matching_arg_count + bp.getMatchingArgCount()
nf1_notmatching_arg_count = nf1_notmatching_arg_count + bp.getNotMatchingArgCount()
diff --git a/FindMissingLineNo.py b/FindMissingLineNo.py
index c92b5ed4..ee25a1f8 100755
--- a/FindMissingLineNo.py
+++ b/FindMissingLineNo.py
@@ -40,9 +40,7 @@ xfailed_lines = {}
read_inputfile(XFAIL_FILE, xfailed_lines)
dbg_line_items = dbg_lines.items()
-for f in range(len(dbg_line_items)):
- fname = dbg_line_items[f][0]
- fset = dbg_line_items[f][1]
+for fname, fset in dbg_line_items:
optset = dbg_opt_lines.get(fname)
nativeoptset = native_dbg_opt_lines.get(fname)
xfailedset = xfailed_lines.get(os.path.basename(fname))