Skip to content

Commit 859db53

Browse files
author
Max Moiseev
committed
Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines
2 parents a61d9d0 + e94fcac commit 859db53

File tree

171 files changed

+1844
-1044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+1844
-1044
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
140140
set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
141141
"The name of the toolchain to pass to 'xcrun'")
142142

143-
set(SWIFT_DARWIN_ICU_INCLUDE_PATH "" CACHE STRING
144-
"Path to the directory where the ICU headers are located")
145-
146143
set(SWIFT_DARWIN_STDLIB_INSTALL_NAME_DIR "@rpath" CACHE STRING
147144
"The directory of the install_name for standard library dylibs")
148145

@@ -307,7 +304,6 @@ set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
307304

308305
set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
309306
set(SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
310-
set(SWIFT_INCLUDE_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/include")
311307
if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
312308
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
313309
endif()

benchmark/scripts/Benchmark_Driver

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def parse_results(res, optset):
6262
tests.append(mem_test)
6363
return tests
6464

65-
def submit_to_LNT(data, url):
65+
def submit_to_lnt(data, url):
6666
print "\nSubmitting results to LNT server..."
6767
json_report = {'input_data': json.dumps(data), 'commit': '1'}
6868
data = urllib.urlencode(json_report)
@@ -224,7 +224,7 @@ def submit(args):
224224
'Start Time': starttime}
225225
print "End time:\t", endtime
226226

227-
submit_to_LNT(data, args.lnt_host)
227+
submit_to_lnt(data, args.lnt_host)
228228
return 0
229229

230230
def run(args):

benchmark/scripts/compare_perf_tests.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
ShowSpeedup = 1
3636
PrintAllScores = 0
3737

38-
def parseInt(word):
38+
def parse_int(word):
3939
try:
4040
return int(word)
4141
except:
4242
raise Exception("Expected integer value, not " + word)
4343

44-
def getScores(fname):
44+
def get_scores(fname):
4545
scores = {}
4646
worstscores = {}
4747
nums = {}
@@ -65,8 +65,8 @@ def getScores(fname):
6565
if not m.group(KEYGROUP) in scores:
6666
scores[m.group(KEYGROUP)] = []
6767
worstscores[m.group(KEYGROUP)] = []
68-
scores[m.group(KEYGROUP)].append(parseInt(m.group(BESTGROUP)))
69-
worstscores[m.group(KEYGROUP)].append(parseInt(m.group(WORSTGROUP)))
68+
scores[m.group(KEYGROUP)].append(parse_int(m.group(BESTGROUP)))
69+
worstscores[m.group(KEYGROUP)].append(parse_int(m.group(WORSTGROUP)))
7070
if is_total:
7171
nums[m.group(KEYGROUP)] = ""
7272
else:
@@ -77,10 +77,10 @@ def getScores(fname):
7777
f.close()
7878
return scores, worstscores, runs, nums
7979

80-
def isMaxScore(newscore, maxscore, invert):
80+
def is_max_score(newscore, maxscore, invert):
8181
return not maxscore or (newscore > maxscore if not invert else newscore < maxscore)
8282

83-
def compareScores(key, score1, worstsample1, score2, worstsample2, runs, num):
83+
def compare_scores(key, score1, worstsample1, score2, worstsample2, runs, num):
8484
print num.rjust(3),
8585
print key.ljust(25),
8686
bestscore1 = None
@@ -91,25 +91,25 @@ def compareScores(key, score1, worstsample1, score2, worstsample2, runs, num):
9191
minworst = not minbest
9292
r = 0
9393
for score in score1:
94-
if isMaxScore(newscore=score, maxscore=bestscore1, invert=minbest):
94+
if is_max_score(newscore=score, maxscore=bestscore1, invert=minbest):
9595
bestscore1 = score
96-
if isMaxScore(newscore=score, maxscore=worstscore1, invert=minworst):
96+
if is_max_score(newscore=score, maxscore=worstscore1, invert=minworst):
9797
worstscore1 = score
9898
if PrintAllScores:
9999
print ("%d" % score).rjust(16),
100100
for score in worstsample1:
101-
if isMaxScore(newscore=score, maxscore=worstscore1, invert=minworst):
101+
if is_max_score(newscore=score, maxscore=worstscore1, invert=minworst):
102102
worstscore1 = score
103103
for score in score2:
104-
if isMaxScore(newscore=score, maxscore=bestscore2, invert=minbest):
104+
if is_max_score(newscore=score, maxscore=bestscore2, invert=minbest):
105105
bestscore2 = score
106-
if isMaxScore(newscore=score, maxscore=worstscore2, invert=minworst):
106+
if is_max_score(newscore=score, maxscore=worstscore2, invert=minworst):
107107
worstscore2 = score
108108
if PrintAllScores:
109109
print ("%d" % score).rjust(16),
110110
r += 1
111111
for score in worstsample2:
112-
if isMaxScore(newscore=score, maxscore=worstscore2, invert=minworst):
112+
if is_max_score(newscore=score, maxscore=worstscore2, invert=minworst):
113113
worstscore2 = score
114114
while r < runs:
115115
if PrintAllScores:
@@ -136,20 +136,20 @@ def compareScores(key, score1, worstsample1, score2, worstsample2, runs, num):
136136
# check if the worst->best interval for each configuration overlap.
137137
if minbest:
138138
if (bestscore1 < bestscore2 and bestscore2 < worstscore1) \
139-
or (bestscore2 < bestscore1 and bestscore1 < worstscore2):
139+
or (bestscore2 < bestscore1 and bestscore1 < worstscore2):
140140
print "(?)",
141141
else:
142142
if (worstscore1 < worstscore2 and worstscore2 < bestscore1) \
143-
or (worstscore2 < worstscore1 and worstscore1 < bestscore2):
143+
or (worstscore2 < worstscore1 and worstscore1 < bestscore2):
144144
print "(?)",
145145
print
146146

147-
def printBestScores(key, scores):
147+
def print_best_scores(key, scores):
148148
print key,
149149
bestscore = None
150150
minbest = IsTime
151151
for score in scores:
152-
if isMaxScore(newscore=score, maxscore=bestscore, invert=minbest):
152+
if is_max_score(newscore=score, maxscore=bestscore, invert=minbest):
153153
bestscore = score
154154
print ", %d" % bestscore
155155

@@ -163,19 +163,19 @@ def usage():
163163
sys.exit(1)
164164
file1 = sys.argv[1]
165165
if len(sys.argv) < 3:
166-
scores, worstscores, runs, nums = getScores(file1)
166+
scores, worstscores, runs, nums = get_scores(file1)
167167
keys = list(set(scores.keys()))
168168
keys.sort()
169169
for key in keys:
170-
printBestScores(key, scores[key])
170+
print_best_scores(key, scores[key])
171171
sys.exit(0)
172172

173173
file2 = sys.argv[2]
174174
if len(sys.argv) > 3:
175175
SCORERE = re.compile(sys.argv[3])
176176

177-
scores1, worstscores1, runs1, nums = getScores(file1)
178-
scores2, worstscores2, runs2, nums = getScores(file2)
177+
scores1, worstscores1, runs1, nums = get_scores(file1)
178+
scores2, worstscores2, runs2, nums = get_scores(file2)
179179

180180
runs = runs1
181181
if runs2 > runs:
@@ -213,4 +213,4 @@ def usage():
213213
if key not in scores2:
214214
print key, "not in", file2
215215
continue
216-
compareScores(key, scores1[key], worstscores1[key], scores2[key], worstscores2[key], runs, nums[key])
216+
compare_scores(key, scores1[key], worstscores1[key], scores2[key], worstscores2[key], runs, nums[key])

cmake/modules/AddSwift.cmake

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ function(_add_variant_c_compile_link_flags)
8989
"-F" "${SWIFT_SDK_${CFLAGS_SDK}_PATH}/../../../Developer/Library/Frameworks"
9090
"-m${SWIFT_SDK_${CFLAGS_SDK}_VERSION_MIN_NAME}-version-min=${DEPLOYMENT_VERSION}")
9191

92-
if(analyze_code_coverage)
92+
if(CFLAGS_ANALYZE_CODE_COVERAGE)
9393
list(APPEND result "-fprofile-instr-generate"
9494
"-fcoverage-mapping")
9595
endif()
96+
endif()
9697

97-
if(enable_lto)
98-
list(APPEND result "-flto")
99-
endif()
98+
if(CFLAGS_ENABLE_LTO)
99+
list(APPEND result "-flto")
100100
endif()
101101

102102
set("${CFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)
@@ -117,7 +117,7 @@ function(_add_variant_c_compile_flags)
117117
ARCH "${CFLAGS_ARCH}"
118118
BUILD_TYPE "${CFLAGS_BUILD_TYPE}"
119119
ENABLE_ASSERTIONS "${CFLAGS_ENABLE_ASSERTIONS}"
120-
SWIFT_ENABLE_LTO "${SWIFT_ENABLE_LTO}"
120+
ENABLE_LTO "${SWIFT_ENABLE_LTO}"
121121
ANALYZE_CODE_COVERAGE FALSE
122122
DEPLOYMENT_VERSION_IOS "${CFLAGS_DEPLOYMENT_VERSION_IOS}"
123123
RESULT_VAR_NAME result)
@@ -136,7 +136,11 @@ function(_add_variant_c_compile_flags)
136136

137137
is_build_type_with_debuginfo("${CFLAGS_BUILD_TYPE}" debuginfo)
138138
if(debuginfo)
139-
list(APPEND result "-g")
139+
if(SWIFT_ENABLE_LTO)
140+
list(APPEND result "-gline-tables-only")
141+
else()
142+
list(APPEND result "-g")
143+
endif()
140144
else()
141145
list(APPEND result "-g0")
142146
endif()
@@ -1859,6 +1863,8 @@ function(add_swift_target_executable name)
18591863

18601864
# All Swift executables depend on the standard library.
18611865
list(APPEND SWIFTEXE_TARGET_LINK_FAT_LIBRARIES swiftCore)
1866+
# All Swift executables depend on the swiftSwiftOnoneSupport library.
1867+
list(APPEND SWIFTEXE_TARGET_DEPENDS swiftSwiftOnoneSupport)
18621868

18631869
if(NOT "${SWIFT_BUILD_STDLIB}")
18641870
list(REMOVE_ITEM SWIFTEXE_TARGET_LINK_FAT_LIBRARIES

include/swift/AST/ASTPrinter.h

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ enum class PrintNameContext {
4747
class ASTPrinter {
4848
unsigned CurrentIndentation = 0;
4949
unsigned PendingNewlines = 0;
50-
const Decl *PendingDeclPreCallback = nullptr;
50+
/// The queue of pending printDeclPre callbacks that will be run when we print
51+
/// a non-whitespace character.
52+
SmallVector<const Decl *, 4> PendingDeclPreCallbacks;
5153
const Decl *PendingDeclLocCallback = nullptr;
5254
Optional<PrintNameContext> PendingNamePreCallback;
5355
const NominalTypeDecl *SynthesizeTarget = nullptr;
@@ -59,19 +61,29 @@ class ASTPrinter {
5961

6062
virtual void printText(StringRef Text) = 0;
6163

64+
// MARK: Callback interface.
65+
6266
/// Called after the printer decides not to print D.
67+
///
68+
/// Callers should use callAvoidPrintDeclPost().
6369
virtual void avoidPrintDeclPost(const Decl *D) {};
6470
/// Called before printing of a declaration.
71+
///
72+
/// Callers should use callPrintDeclPre().
6573
virtual void printDeclPre(const Decl *D) {}
6674
/// Called before printing at the point which would be considered the location
6775
/// of the declaration (normally the name of the declaration).
76+
///
77+
/// Callers should use callPrintDeclLoc().
6878
virtual void printDeclLoc(const Decl *D) {}
6979
/// Called after printing the name of the declaration.
7080
virtual void printDeclNameEndLoc(const Decl *D) {}
7181
/// Called after printing the name of a declaration, or in the case of
7282
/// functions its signature.
7383
virtual void printDeclNameOrSignatureEndLoc(const Decl *D) {}
7484
/// Called after finishing printing of a declaration.
85+
///
86+
/// Callers should use callPrintDeclPost().
7587
virtual void printDeclPost(const Decl *D) {}
7688

7789
/// Called before printing a type.
@@ -127,6 +139,9 @@ class ASTPrinter {
127139
}
128140

129141
void setSynthesizedTarget(NominalTypeDecl *Target) {
142+
assert((!SynthesizeTarget || !Target || Target == SynthesizeTarget) &&
143+
"unexpected change of setSynthesizedTarget");
144+
// FIXME: this can overwrite the original target with nullptr.
130145
SynthesizeTarget = Target;
131146
}
132147

@@ -136,21 +151,48 @@ class ASTPrinter {
136151

137152
virtual void printIndent();
138153

154+
// MARK: Callback interface wrappers that perform ASTPrinter bookkeeping.
155+
139156
/// Schedule a \c printDeclPre callback to be called as soon as a
140157
/// non-whitespace character is printed.
141158
void callPrintDeclPre(const Decl *D) {
142-
PendingDeclPreCallback = D;
159+
PendingDeclPreCallbacks.emplace_back(D);
160+
}
161+
162+
/// Make a callback to printDeclPost(), performing any necessary bookeeping.
163+
void callPrintDeclPost(const Decl *D) {
164+
if (!PendingDeclPreCallbacks.empty() &&
165+
PendingDeclPreCallbacks.back() == D) {
166+
// Nothing printed for D; skip both pre and post callbacks.
167+
// Ideally we wouldn't get as far as setting up the callback if we aren't
168+
// going to print anything, but currently that would mean walking the
169+
// children of top-level code decls to determine.
170+
PendingDeclPreCallbacks.pop_back();
171+
return;
172+
}
173+
printDeclPost(D);
174+
}
175+
176+
/// Make a callback to avoidPrintDeclPost(), performing any necessary
177+
/// bookkeeping.
178+
void callAvoidPrintDeclPost(const Decl *D) {
179+
assert((PendingDeclPreCallbacks.empty() ||
180+
PendingDeclPreCallbacks.back() != D) &&
181+
"printDeclPre should not be called on avoided decl");
182+
avoidPrintDeclPost(D);
143183
}
144184

145185
/// Schedule a \c printDeclLoc callback to be called as soon as a
146186
/// non-whitespace character is printed.
147187
void callPrintDeclLoc(const Decl *D) {
188+
assert(!PendingDeclLocCallback && "unexpected nested callPrintDeclLoc");
148189
PendingDeclLocCallback = D;
149190
}
150191

151192
/// Schedule a \c printNamePre callback to be called as soon as a
152193
/// non-whitespace character is printed.
153194
void callPrintNamePre(PrintNameContext Context) {
195+
assert(!PendingNamePreCallback && "unexpected nested callPrintNamePre");
154196
PendingNamePreCallback = Context;
155197
}
156198

include/swift/AST/Decl.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "swift/AST/CaptureInfo.h"
2121
#include "swift/AST/ClangNode.h"
22+
#include "swift/AST/ConcreteDeclRef.h"
2223
#include "swift/AST/DefaultArgumentKind.h"
2324
#include "swift/AST/ExprHandle.h"
2425
#include "swift/AST/GenericSignature.h"
@@ -3609,17 +3610,20 @@ enum class AccessStrategy : unsigned char {
36093610
struct BehaviorRecord {
36103611
// The behavior name.
36113612
TypeRepr *ProtocolName;
3612-
// The parameter function, if any.
3613-
FuncDecl *Param;
3613+
// The parameter expression, if any.
3614+
Expr *Param;
36143615

36153616
Optional<NormalProtocolConformance *> Conformance = None;
36163617
// The 'value' property from the behavior protocol that provides the property
36173618
// implementation.
36183619
VarDecl *ValueDecl = nullptr;
36193620

3621+
// Storage declaration and initializer for use by definite initialization.
3622+
VarDecl *StorageDecl = nullptr;
3623+
ConcreteDeclRef InitStorageDecl = nullptr;
36203624

36213625
BehaviorRecord(TypeRepr *ProtocolName,
3622-
FuncDecl *Param)
3626+
Expr *Param)
36233627
: ProtocolName(ProtocolName), Param(Param)
36243628
{}
36253629

@@ -3919,7 +3923,7 @@ class AbstractStorageDecl : public ValueDecl {
39193923
void setComputedSetter(FuncDecl *Set);
39203924

39213925
/// \brief Add a behavior to a property.
3922-
void addBehavior(TypeRepr *Type, FuncDecl *Param);
3926+
void addBehavior(TypeRepr *Type, Expr *Param);
39233927

39243928
/// \brief Set a materializeForSet accessor for this declaration.
39253929
///

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ ERROR(error_unsupported_target_os, none,
5252
ERROR(error_unsupported_target_arch, none,
5353
"unsupported target architecture: '%0'", (StringRef))
5454

55+
ERROR(error_unsupported_opt_for_target, none,
56+
"unsupported option '%0' for target '%1'", (StringRef, StringRef))
57+
5558
ERROR(cannot_open_file,none,
5659
"cannot open file '%0' (%1)", (StringRef, StringRef))
5760
ERROR(cannot_open_serialized_file,none,
@@ -67,6 +70,8 @@ ERROR(error_unknown_arg,none,
6770
"unknown argument: '%0'", (StringRef))
6871
ERROR(error_invalid_arg_value,none,
6972
"invalid value '%1' in '%0'", (StringRef, StringRef))
73+
ERROR(error_unsupported_option_argument,none,
74+
"unsupported argument '%1' to option '%0'", (StringRef, StringRef))
7075
ERROR(error_immediate_mode_missing_stdlib,none,
7176
"could not load the swift standard library", ())
7277
ERROR(error_immediate_mode_missing_library,none,

include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ ERROR(addressor_with_getter,none,
256256
ERROR(addressor_with_setter,none,
257257
"%select{variable|subscript}0 cannot provide both 'address' and "
258258
"a setter; use an ordinary getter instead", (unsigned))
259+
ERROR(behavior_multiple_vars,none,
260+
"applying property behavior with parameter to multiple variables is "
261+
"not supported", ())
259262

260263
// Import
261264
ERROR(decl_expected_module_name,none,

0 commit comments

Comments
 (0)