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 {
249249 bool PrintWarning;
250250
251251public:
252+ const static unsigned NoLimit = (unsigned ) -1 ;
253+
252254 ExpressionTimer (AnchorType Anchor, ConstraintSystem &CS,
253255 unsigned thresholdInSecs);
254256
@@ -274,6 +276,9 @@ class ExpressionTimer {
274276 // / Return the remaining process time in seconds until the
275277 // / threshold specified during construction is reached.
276278 unsigned getRemainingProcessTimeInSeconds () const {
279+ if (ThresholdInSecs == NoLimit)
280+ return NoLimit;
281+
277282 auto elapsed = unsigned (getElapsedProcessTimeInFractionalSeconds ());
278283 return elapsed >= ThresholdInSecs ? 0 : ThresholdInSecs - elapsed;
279284 }
Original file line number Diff line number Diff line change @@ -141,9 +141,18 @@ ConstraintSystem::~ConstraintSystem() {
141141void ConstraintSystem::startExpressionTimer (ExpressionTimer::AnchorType anchor) {
142142 ASSERT (!Timer);
143143
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+ }
147156
148157 Timer.emplace (anchor, *this , timeout);
149158}
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
32@_silgen_name ( " generic_foo " )
43func foo< T> ( _ x: T ) -> T
54
@@ -8,6 +7,6 @@ func foo(_ x: Int) -> Int
87
98func test( m: Double ) -> Int {
109 // expected-warning@-1 {{global function 'test(m:)' took}}
11- return Int ( foo ( Float ( m ) / 20 ) * 20 - 2 ) + 10
10+ return ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( ~ ( 0 ) ) ) ) ) ) ) ) ) ) ) )
1211 // expected-warning@-1 {{expression took}}
1312}
You can’t perform that action at this time.
0 commit comments