Skip to content

Commit c311b29

Browse files
committed
---
yaml --- r: 345807 b: refs/heads/master c: 65d3249 h: refs/heads/master i: 345805: 0e7c336 345803: 1f3496a 345799: 00487c5 345791: 864bfb9
1 parent 9ca1821 commit c311b29

File tree

21 files changed

+94
-62
lines changed

21 files changed

+94
-62
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e9fb52c5ab04bd8cd73734befc62cbb5bc7a5d76
2+
refs/heads/master: 65d32495c2355f9acb2851a539613e689b07d4f9
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore = W291
2+
ignore = W291 W504
33
filename = *.py,
44
./utils/80+-check,
55
./utils/backtrace-check,

trunk/benchmark/scripts/Benchmark_RuntimeLeaksRunner.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ def parse_args():
151151

152152
if __name__ == "__main__":
153153
args = parse_args()
154-
l = LeaksRunnerBenchmarkDriver(
154+
driver = LeaksRunnerBenchmarkDriver(
155155
SWIFT_BIN_DIR, XFAIL_LIST, args.num_samples, args.num_iters)
156-
if l.run(args.filter):
156+
if driver.run(args.filter):
157157
sys.exit(0)
158158
else:
159159
sys.exit(-1)

trunk/benchmark/scripts/test_compare_perf_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ def test_results_from_merge(self):
591591
def test_results_from_merge_verbose(self):
592592
"""Parsing verbose log merges all PerformanceTestSamples.
593593
...this should technically be on TestPerformanceTestResult, but it's
594-
easier to write here. ¯\_(ツ)_/¯"""
594+
easier to write here. ¯\\_(ツ)_/¯"""
595595
concatenated_logs = """
596596
Sample 0,355883
597597
Sample 1,358817

trunk/tools/SourceKit/tools/swift-lang/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if(NOT SWIFT_SOURCEKIT_USE_INPROC_LIBRARY AND SWIFT_BUILD_STDLIB)
1313
UIDs.swift.gyb
1414

1515
DEPENDS ${DEPENDS_LIST}
16-
SWIFT_MODULE_DEPENDS_OSX Darwin
16+
SWIFT_MODULE_DEPENDS_OSX Darwin Foundation
1717
PRIVATE_LINK_LIBRARIES ${SOURCEKITD_LINK_LIBS}
1818
SWIFT_COMPILE_FLAGS ${EXTRA_COMPILE_FLAGS}
1919
INSTALL_IN_COMPONENT ${INSTALLED_COMP}

trunk/tools/SourceKit/tools/swift-lang/SourceKitdResponse.swift

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@
1212
// This file provides convenient APIs to interpret a SourceKitd response.
1313
//===----------------------------------------------------------------------===//
1414

15+
import Foundation
1516
import sourcekitd
1617

1718
public class SourceKitdResponse: CustomStringConvertible {
1819

1920
public struct Dictionary: CustomStringConvertible, CustomReflectable {
21+
// The lifetime of this sourcekitd_variant_t is tied to the response it came
22+
// from, so keep a reference to the response too.
2023
private let dict: sourcekitd_variant_t
24+
private let context: SourceKitdResponse
2125

22-
public init(dict: sourcekitd_variant_t) {
26+
27+
public init(dict: sourcekitd_variant_t, context: SourceKitdResponse) {
2328
assert(sourcekitd_variant_get_type(dict).rawValue ==
2429
SOURCEKITD_VARIANT_TYPE_DICTIONARY.rawValue)
2530
self.dict = dict
31+
self.context = context
2632
}
2733

2834
public func getString(_ key: SourceKitdUID) -> String {
@@ -47,12 +53,21 @@ public class SourceKitdResponse: CustomStringConvertible {
4753

4854
public func getArray(_ key: SourceKitdUID) -> Array {
4955
let value = sourcekitd_variant_dictionary_get_value(dict, key.uid)
50-
return Array(arr: value)
56+
return Array(arr: value, context: context)
5157
}
5258

5359
public func getDictionary(_ key: SourceKitdUID) -> Dictionary {
5460
let value = sourcekitd_variant_dictionary_get_value(dict, key.uid)
55-
return Dictionary(dict: value)
61+
return Dictionary(dict: value, context: context)
62+
}
63+
64+
public func getData(_ key: SourceKitdUID) -> Data {
65+
let value = sourcekitd_variant_dictionary_get_value(dict, key.uid)
66+
let size = sourcekitd_variant_data_get_size(value)
67+
guard let ptr = sourcekitd_variant_data_get_ptr(value), size > 0 else {
68+
return Data()
69+
}
70+
return Data(bytes: ptr, count: size)
5671
}
5772

5873
public func getOptional(_ key: SourceKitdUID) -> Variant? {
@@ -61,7 +76,7 @@ public class SourceKitdResponse: CustomStringConvertible {
6176
SOURCEKITD_VARIANT_TYPE_NULL.rawValue {
6277
return nil
6378
}
64-
return Variant(val: value)
79+
return Variant(val: value, context: context)
6580
}
6681

6782
public var description: String {
@@ -74,17 +89,21 @@ public class SourceKitdResponse: CustomStringConvertible {
7489
}
7590

7691
public struct Array: CustomStringConvertible {
92+
// The lifetime of this sourcekitd_variant_t is tied to the response it came
93+
// from, so keep a reference to the response too.
7794
private let arr: sourcekitd_variant_t
95+
private let context: SourceKitdResponse
7896

7997
public var count: Int {
8098
let count = sourcekitd_variant_array_get_count(arr)
8199
return Int(count)
82100
}
83101

84-
public init(arr: sourcekitd_variant_t) {
102+
public init(arr: sourcekitd_variant_t, context: SourceKitdResponse) {
85103
assert(sourcekitd_variant_get_type(arr).rawValue ==
86104
SOURCEKITD_VARIANT_TYPE_ARRAY.rawValue)
87105
self.arr = arr
106+
self.context = context
88107
}
89108

90109
public func getString(_ index: Int) -> String {
@@ -109,20 +128,21 @@ public class SourceKitdResponse: CustomStringConvertible {
109128

110129
public func getArray(_ index: Int) -> Array {
111130
let value = sourcekitd_variant_array_get_value(arr, index)
112-
return Array(arr: value)
131+
return Array(arr: value, context: context)
113132
}
114133

115134
public func getDictionary(_ index: Int) -> Dictionary {
116135
let value = sourcekitd_variant_array_get_value(arr, index)
117-
return Dictionary(dict: value)
136+
return Dictionary(dict: value, context: context)
118137
}
119138

120139
public func enumerate(_ applier: (_ index: Int, _ value: Variant) -> Bool) {
121140
// The block passed to sourcekit_variant_array_apply() does not actually
122141
// escape, it's synchronous and not called after returning.
142+
let context = self.context
123143
withoutActuallyEscaping(applier) { escapingApplier in
124144
_ = sourcekitd_variant_array_apply(arr) { (index, elem) -> Bool in
125-
return escapingApplier(Int(index), Variant(val: elem))
145+
return escapingApplier(Int(index), Variant(val: elem, context: context))
126146
}
127147
}
128148
}
@@ -134,10 +154,14 @@ public class SourceKitdResponse: CustomStringConvertible {
134154
}
135155

136156
public struct Variant: CustomStringConvertible {
157+
// The lifetime of this sourcekitd_variant_t is tied to the response it came
158+
// from, so keep a reference to the response too.
137159
private let val: sourcekitd_variant_t
160+
fileprivate let context: SourceKitdResponse
138161

139-
fileprivate init(val: sourcekitd_variant_t) {
162+
fileprivate init(val: sourcekitd_variant_t, context: SourceKitdResponse) {
140163
self.val = val
164+
self.context = context
141165
}
142166

143167
public func getString() -> String {
@@ -167,11 +191,19 @@ public class SourceKitdResponse: CustomStringConvertible {
167191
}
168192

169193
public func getArray() -> Array {
170-
return Array(arr: val)
194+
return Array(arr: val, context: context)
171195
}
172196

173197
public func getDictionary() -> Dictionary {
174-
return Dictionary(dict: val)
198+
return Dictionary(dict: val, context: context)
199+
}
200+
201+
public func getData() -> Data {
202+
let size = sourcekitd_variant_data_get_size(val)
203+
guard let ptr = sourcekitd_variant_data_get_ptr(val), size > 0 else {
204+
return Data()
205+
}
206+
return Data(bytes: ptr, count: size)
175207
}
176208

177209
public var description: String {
@@ -182,7 +214,7 @@ public class SourceKitdResponse: CustomStringConvertible {
182214
private let resp: sourcekitd_response_t
183215

184216
public var value: Dictionary {
185-
return Dictionary(dict: sourcekitd_response_get_value(resp))
217+
return Dictionary(dict: sourcekitd_response_get_value(resp), context: self)
186218
}
187219

188220
/// Copies the raw bytes of the JSON description of this documentation item.

trunk/utils/backtrace-check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ formatting.""")
3636
args = parser.parse_args()
3737

3838
TARGET_RE = re.compile(
39-
"(?P<index>\d+) +(?P<object>\S+) +(?P<address>0x[0-9a-fA-F]{16}) "
40-
"(?P<routine>[^+]+) [+] (?P<offset>\d+)")
39+
r"(?P<index>\d+) +(?P<object>\S+) +(?P<address>0x[0-9a-fA-F]{16}) "
40+
r"(?P<routine>[^+]+) [+] (?P<offset>\d+)")
4141

4242
lines = sys.stdin.readlines()
4343

4444
found_stack_trace_start = False
4545
found_stack_trace_entry = False
46-
for l in lines:
47-
l = l.rstrip("\n")
46+
for line in lines:
47+
line = line.rstrip("\n")
4848

4949
# First see if we found the start of our stack trace start. If so, set
5050
# the found stack trace flag and continue.
51-
if l == "Current stack trace:":
51+
if line == "Current stack trace:":
5252
assert(not found_stack_trace_start)
5353
found_stack_trace_start = True
5454
continue
@@ -59,7 +59,7 @@ formatting.""")
5959
continue
6060

6161
# Ok, we are in the middle of matching a stack trace entry.
62-
m = TARGET_RE.match(l)
62+
m = TARGET_RE.match(line)
6363
# If we fail to match, we have exited the stack trace entry region
6464
if m is None:
6565
break

trunk/utils/bug_reducer/tests/test_funcbugreducer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_basic(self):
117117
"$s9testbasic6foo413yyF" in output)
118118
re_end = 'testfuncbugreducer_testbasic_'
119119
re_end += '92196894259b5d6c98d1b77f19240904.sib'
120-
output_file_re = re.compile('\*\*\* Final File: .*' + re_end)
120+
output_file_re = re.compile(r'\*\*\* Final File: .*' + re_end)
121121
output_matches = [
122122
1 for o in output if output_file_re.match(o) is not None]
123123
self.assertEquals(sum(output_matches), 1)

trunk/utils/bug_reducer/tests/test_optbugreducer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_basic(self):
105105
self.assertTrue('*** Found miscompiling passes!' in output)
106106
self.assertTrue('*** Final Passes: --bug-reducer-tester' in output)
107107
re_end = 'testoptbugreducer_testbasic_initial'
108-
output_file_re = re.compile('\*\*\* Final File: .*' + re_end)
108+
output_file_re = re.compile(r'\*\*\* Final File: .*' + re_end)
109109
output_matches = [
110110
1 for o in output if output_file_re.match(o) is not None]
111111
self.assertEquals(sum(output_matches), 1)
@@ -134,7 +134,7 @@ def test_suffix_in_need_of_prefix(self):
134134
self.assertTrue('*** Found miscompiling passes!' in output)
135135
self.assertTrue('*** Final Passes: --bug-reducer-tester' in output)
136136
re_end = 'testoptbugreducer_testsuffixinneedofprefix_initial'
137-
output_file_re = re.compile('\*\*\* Final File: .*' + re_end)
137+
output_file_re = re.compile(r'\*\*\* Final File: .*' + re_end)
138138
output_matches = [
139139
1 for o in output if output_file_re.match(o) is not None]
140140
self.assertEquals(sum(output_matches), 1)
@@ -167,7 +167,7 @@ def test_reduce_function(self):
167167
self.assertTrue('*** Final Passes: --bug-reducer-tester' in output)
168168
re_end = 'testoptbugreducer_testreducefunction_initial_'
169169
re_end += '30775a3d942671a403702a9846afa7a4.sib'
170-
output_file_re = re.compile('\*\*\* Final File: .*' + re_end)
170+
output_file_re = re.compile(r'\*\*\* Final File: .*' + re_end)
171171
output_matches = [
172172
1 for o in output if output_file_re.match(o) is not None]
173173
self.assertEquals(sum(output_matches), 1)

trunk/utils/cmpcodesize/cmpcodesize/compare.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
["CPP", re.compile('^(__Z|_+swift)')],
2222

2323
# Objective-C
24-
["ObjC", re.compile('^[+-]\[')],
24+
["ObjC", re.compile(r'^[+-]\[')],
2525

2626
# Swift
2727
["Partial Apply", re.compile('^__(TPA|T0.*T[aA]$)')],
@@ -80,7 +80,7 @@ def read_sizes(sizes, file_name, function_details, group_by_prefix):
8080
architectures = subprocess.check_output(
8181
["otool", "-V", "-f", file_name]).split("\n")
8282
arch = None
83-
arch_pattern = re.compile('architecture ([\S]+)')
83+
arch_pattern = re.compile(r'architecture ([\S]+)')
8484
for architecture in architectures:
8585
arch_match = arch_pattern.match(architecture)
8686
if arch_match:
@@ -115,10 +115,10 @@ def read_sizes(sizes, file_name, function_details, group_by_prefix):
115115
start_addr = None
116116
end_addr = None
117117

118-
section_pattern = re.compile(' +sectname ([\S]+)')
119-
size_pattern = re.compile(' +size ([\da-fx]+)')
120-
asmline_pattern = re.compile('^([0-9a-fA-F]+)\s')
121-
label_pattern = re.compile('^((\-*\[[^\]]*\])|[^\/\s]+):$')
118+
section_pattern = re.compile(r' +sectname ([\S]+)')
119+
size_pattern = re.compile(r' +size ([\da-fx]+)')
120+
asmline_pattern = re.compile(r'^([0-9a-fA-F]+)\s')
121+
label_pattern = re.compile(r'^((\-*\[[^\]]*\])|[^\/\s]+):$')
122122

123123
for line in content:
124124
asmline_match = asmline_pattern.match(line)

trunk/utils/create-filecheck-test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
args = parser.parse_args()
2626

2727
seen_variables = set([])
28-
ssa_re = re.compile('[%](\d+)')
29-
for l in args.input.readlines():
30-
l = l[:l.find('//')].rstrip() + "\n"
28+
ssa_re = re.compile(r'[%](\d+)')
29+
for line in args.input.readlines():
30+
line = line[:line.find('//')].rstrip() + "\n"
3131
have_match = False
32-
for match in ssa_re.finditer(l):
32+
for match in ssa_re.finditer(line):
3333
have_match = True
3434
var = match.groups()[0]
3535
if var not in seen_variables:
36-
l = l.replace('%' + var, '[[VAR_%s:%%[0-9]+]]' % var)
36+
line = line.replace('%' + var, '[[VAR_%s:%%[0-9]+]]' % var)
3737
seen_variables.add(var)
3838
else:
39-
l = l.replace('%' + var, '[[VAR_%s]]' % var)
39+
line = line.replace('%' + var, '[[VAR_%s]]' % var)
4040
if have_match:
41-
l = '// CHECK: ' + l
42-
args.o.write(l)
41+
line = '// CHECK: ' + line
42+
args.o.write(line)

trunk/utils/generate_confusables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def main(args=sys.argv):
5757

5858
pairs = []
5959
with open(confusablesFilePath, 'r') as f:
60-
pattern = re.compile("(.+)\W+;\W+(.+)\W+;")
60+
pattern = re.compile(r"(.+)\W+;\W+(.+)\W+;")
6161
for line in f:
6262
match = pattern.match(line)
6363
if match is not None:

trunk/utils/gyb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def split_lines(s):
9999
)
100100
''', re.VERBOSE | re.MULTILINE)
101101

102-
gyb_block_close = re.compile('\}%[ \t]*\n?')
102+
gyb_block_close = re.compile(r'\}%[ \t]*\n?')
103103

104104

105105
def token_pos_to_index(token_pos, start, line_starts):

trunk/utils/jobstats/jobstats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def to_lnt_test_obj(self, args):
199199
AUXPAT = re.compile(AUXPATSTR)
200200

201201
TIMERPATSTR = (r"time\.swift-(?P<jobkind>\w+)\." + AUXPATSTR +
202-
"\.(?P<timerkind>\w+)$")
202+
r"\.(?P<timerkind>\w+)$")
203203
TIMERPAT = re.compile(TIMERPATSTR)
204204

205205
FILEPATSTR = (r"^stats-(?P<start>\d+)-swift-(?P<kind>\w+)-" +
@@ -266,7 +266,7 @@ def find_profiles_in(profiledir, select_stat=[]):
266266
if profiletype not in profiles:
267267
profiles[profiletype] = dict()
268268
profiles[profiletype][counter] = fullpath
269-
except:
269+
except Exception:
270270
pass
271271
return profiles
272272

trunk/utils/pass-pipeline/scripts/pipelines_build_script.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def run_build_script_with_data_file(build_script, data_file, verbose=False):
2424
build_script_args = [
2525
build_script,
2626
DEFAULT_PRESENTS,
27-
'extra_swift_args=^Swift$;-Xfrontend\;' +
28-
'-external-pass-pipeline-filename\;-Xfrontend\;%s' % data_file]
27+
r'extra_swift_args=^Swift$;-Xfrontend\;' +
28+
r'-external-pass-pipeline-filename\;-Xfrontend\;%s' % data_file]
2929
sys.stdout.write("Running build script with: %s..." %
3030
' '.join(build_script_args))
3131
sys.stdout.flush()

0 commit comments

Comments
 (0)