Skip to content

Commit dec7fd6

Browse files
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 llvm-svn: 350381
1 parent 471b1e4 commit dec7fd6

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

CompareDebugInfo.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,23 @@ def recordArgument(self, arg_name, value):
4646

4747
def __repr__(self):
4848
print self.name
49-
items = self.values.items()
50-
for i in range(len(items)):
51-
print items[i][0]," = ",items[i][1]
49+
for k, v in self.values.items():
50+
print k, "=", v
5251
return ''
5352

5453
def compare_args(self, other, file):
5554
myitems = self.values.items()
5655
otheritems = other.values.items()
5756
match = False
58-
for i in range(len(myitems)):
57+
for i, my_item in enumerate(my_items):
5958
if i >= len(otheritems):
6059
match = True
61-
self.missing_args.append(myitems[i][0])
62-
elif cmp(myitems[i][1], otheritems[i][1]):
60+
self.missing_args.append(myitem[0])
61+
elif cmp(myitem[1], otheritems[i][1]):
6362
match = True
64-
self.notmatching_args.append(myitems[i][0])
63+
self.notmatching_args.append(myitem[0])
6564
else:
66-
self.matching_args.append(myitems[i][0])
65+
self.matching_args.append(myitem[0])
6766

6867
self.print_list(self.matching_args, " Matching arguments ", file)
6968
self.print_list(self.notmatching_args, " Not Matching arguments ", file)
@@ -108,9 +107,7 @@ def read_input(filename, dict):
108107

109108
f = open(LOG_FILE, "w")
110109
f.write("Log output\n")
111-
for f2bp in range(len(f2_items)):
112-
id = f2_items[f2bp][0]
113-
bp = f2_items[f2bp][1]
110+
for id, bp in f2_items:
114111
bp1 = f1_breakpoints.get(id)
115112
if bp1 is None:
116113
bp.setMissing()
@@ -127,9 +124,7 @@ def read_input(filename, dict):
127124
nf2_items = nf2_breakpoints.items()
128125

129126
nfl = open(NATIVE_LOG_FILE, "w")
130-
for nf2bp in range(len(nf2_items)):
131-
id = nf2_items[nf2bp][0]
132-
bp = nf2_items[nf2bp][1]
127+
for id, bp in nf2_items:
133128
bp1 = nf1_breakpoints.get(id)
134129
if bp1 is None:
135130
bp.setMissing()
@@ -141,8 +136,8 @@ def read_input(filename, dict):
141136
f1_matching_arg_count = 0
142137
f1_notmatching_arg_count = 0
143138
f1_missing_arg_count = 0
144-
for idx in range(len(f1_items)):
145-
bp = f1_items[idx][1]
139+
for f1_item in f1_items:
140+
bp = f1_item[1]
146141
f1_arg_count = f1_arg_count + bp.getArgCount()
147142
f1_matching_arg_count = f1_matching_arg_count + bp.getMatchingArgCount()
148143
f1_notmatching_arg_count = f1_notmatching_arg_count + bp.getNotMatchingArgCount()
@@ -152,8 +147,8 @@ def read_input(filename, dict):
152147
nf1_matching_arg_count = 0
153148
nf1_notmatching_arg_count = 0
154149
nf1_missing_arg_count = 0
155-
for idx in range(len(nf1_items)):
156-
bp = nf1_items[idx][1]
150+
for nf1_item in nf1_items:
151+
bp = nf1_item[1]
157152
nf1_arg_count = nf1_arg_count + bp.getArgCount()
158153
nf1_matching_arg_count = nf1_matching_arg_count + bp.getMatchingArgCount()
159154
nf1_notmatching_arg_count = nf1_notmatching_arg_count + bp.getNotMatchingArgCount()

FindMissingLineNo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def read_inputfile(filename, dict):
4040
read_inputfile(XFAIL_FILE, xfailed_lines)
4141

4242
dbg_line_items = dbg_lines.items()
43-
for f in range(len(dbg_line_items)):
44-
fname = dbg_line_items[f][0]
45-
fset = dbg_line_items[f][1]
43+
for fname, fset in dbg_line_items:
4644
optset = dbg_opt_lines.get(fname)
4745
nativeoptset = native_dbg_opt_lines.get(fname)
4846
xfailedset = xfailed_lines.get(os.path.basename(fname))

0 commit comments

Comments
 (0)