File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,8 @@ class ExpressionTimer {
249
249
bool PrintWarning;
250
250
251
251
public:
252
+ const static unsigned NoLimit = (unsigned ) -1 ;
253
+
252
254
ExpressionTimer (AnchorType Anchor, ConstraintSystem &CS,
253
255
unsigned thresholdInSecs);
254
256
@@ -274,6 +276,9 @@ class ExpressionTimer {
274
276
// / Return the remaining process time in seconds until the
275
277
// / threshold specified during construction is reached.
276
278
unsigned getRemainingProcessTimeInSeconds () const {
279
+ if (ThresholdInSecs == NoLimit)
280
+ return NoLimit;
281
+
277
282
auto elapsed = unsigned (getElapsedProcessTimeInFractionalSeconds ());
278
283
return elapsed >= ThresholdInSecs ? 0 : ThresholdInSecs - elapsed;
279
284
}
Original file line number Diff line number Diff line change @@ -141,9 +141,18 @@ ConstraintSystem::~ConstraintSystem() {
141
141
void ConstraintSystem::startExpressionTimer (ExpressionTimer::AnchorType anchor) {
142
142
ASSERT (!Timer);
143
143
144
- unsigned timeout = getASTContext ().TypeCheckerOpts .ExpressionTimeoutThreshold ;
145
- if (timeout == 0 )
146
- return ;
144
+ const auto &opts = getASTContext ().TypeCheckerOpts ;
145
+ unsigned timeout = opts.ExpressionTimeoutThreshold ;
146
+
147
+ // If either the timeout is set, or we're asked to emit warnings,
148
+ // start the timer. Otherwise, don't start the timer, it's needless
149
+ // overhead.
150
+ if (timeout == 0 ) {
151
+ if (opts.WarnLongExpressionTypeChecking == 0 )
152
+ return ;
153
+
154
+ timeout = ExpressionTimer::NoLimit;
155
+ }
147
156
148
157
Timer.emplace (anchor, *this , timeout);
149
158
}
Original file line number Diff line number Diff line change 1
- // RUN: %target-typecheck-verify-swift -warn-long-expression-type-checking=1 -warn-long-function-bodies=1
2
- // REQUIRES: rdar44305428
1
+ // RUN: %target-typecheck-verify-swift -warn-long-expression-type-checking=1 -solver-disable-shrink -warn-long-function-bodies=1
3
2
@_silgen_name ( " generic_foo " )
4
3
func foo< T> ( _ x: T ) -> T
5
4
@@ -8,6 +7,6 @@ func foo(_ x: Int) -> Int
8
7
9
8
func test( m: Double ) -> Int {
10
9
// expected-warning@-1 {{global function 'test(m:)' took}}
11
- return Int ( foo ( Float ( m ) / 20 ) * 20 - 2 ) + 10
10
+ return ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( 0 ) ) ) ) ) ) ) ) ) ) ) )
12
11
// expected-warning@-1 {{expression took}}
13
12
}
You can’t perform that action at this time.
0 commit comments