@@ -178,13 +178,9 @@ namespace {
178
178
class FunctionBodyTimer {
179
179
AnyFunctionRef Function;
180
180
llvm::TimeRecord StartTime = llvm::TimeRecord::getCurrentTime();
181
- unsigned WarnLimit;
182
- bool ShouldDump;
183
181
184
182
public:
185
- FunctionBodyTimer (AnyFunctionRef Fn, bool shouldDump,
186
- unsigned warnLimit)
187
- : Function(Fn), WarnLimit(warnLimit), ShouldDump(shouldDump) {}
183
+ FunctionBodyTimer (AnyFunctionRef Fn) : Function(Fn) {}
188
184
189
185
~FunctionBodyTimer () {
190
186
llvm::TimeRecord endTime = llvm::TimeRecord::getCurrentTime (false );
@@ -195,7 +191,7 @@ namespace {
195
191
ASTContext &ctx = Function.getAsDeclContext ()->getASTContext ();
196
192
auto *AFD = Function.getAbstractFunctionDecl ();
197
193
198
- if (ShouldDump ) {
194
+ if (ctx. TypeCheckerOpts . WarnLongFunctionBodies ) {
199
195
// Round up to the nearest 100th of a millisecond.
200
196
llvm::errs () << llvm::format (" %0.2f" , ceil (elapsed * 100000 ) / 100 ) << " ms\t " ;
201
197
Function.getLoc ().print (llvm::errs (), ctx.SourceMgr );
@@ -210,6 +206,7 @@ namespace {
210
206
llvm::errs () << " \n " ;
211
207
}
212
208
209
+ const auto WarnLimit = ctx.TypeCheckerOpts .DebugTimeFunctionBodies ;
213
210
if (WarnLimit != 0 && elapsedMS >= WarnLimit) {
214
211
if (AFD) {
215
212
ctx.Diags .diagnose (AFD, diag::debug_long_function_body,
@@ -1424,7 +1421,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
1424
1421
}
1425
1422
1426
1423
if (!switchStmt->isImplicit ()) {
1427
- TC.checkSwitchExhaustiveness (switchStmt, DC, limitExhaustivityChecks);
1424
+ TypeChecker::checkSwitchExhaustiveness (switchStmt, DC,
1425
+ limitExhaustivityChecks);
1428
1426
}
1429
1427
1430
1428
return switchStmt;
@@ -2110,9 +2108,9 @@ TypeCheckFunctionBodyUntilRequest::evaluate(Evaluator &evaluator,
2110
2108
ctx.Stats ->getFrontendCounters ().NumFunctionsTypechecked ++;
2111
2109
2112
2110
Optional<FunctionBodyTimer> timer;
2113
- TypeChecker &tc = * ctx.getLegacyGlobalTypeChecker () ;
2114
- if (tc .DebugTimeFunctionBodies || tc .WarnLongFunctionBodies )
2115
- timer.emplace (AFD, tc. DebugTimeFunctionBodies , tc. WarnLongFunctionBodies );
2111
+ const auto &tyOpts = ctx.TypeCheckerOpts ;
2112
+ if (tyOpts .DebugTimeFunctionBodies || tyOpts .WarnLongFunctionBodies )
2113
+ timer.emplace (AFD);
2116
2114
2117
2115
BraceStmt *body = AFD->getBody ();
2118
2116
if (!body || AFD->isBodyTypeChecked ())
@@ -2204,11 +2202,10 @@ bool TypeChecker::typeCheckClosureBody(ClosureExpr *closure) {
2204
2202
2205
2203
BraceStmt *body = closure->getBody ();
2206
2204
2207
- auto *TC = closure->getASTContext ().getLegacyGlobalTypeChecker ();
2208
2205
Optional<FunctionBodyTimer> timer;
2209
- if (TC-> DebugTimeFunctionBodies || TC-> WarnLongFunctionBodies )
2210
- timer. emplace (closure, TC-> DebugTimeFunctionBodies ,
2211
- TC-> WarnLongFunctionBodies );
2206
+ const auto &tyOpts = closure-> getASTContext (). TypeCheckerOpts ;
2207
+ if (tyOpts. DebugTimeFunctionBodies || tyOpts. WarnLongFunctionBodies )
2208
+ timer. emplace (closure );
2212
2209
2213
2210
bool HadError = StmtChecker (closure).typeCheckBody (body);
2214
2211
if (body) {
0 commit comments