Skip to content

Commit 9843190

Browse files
committed
[Request-evaluator] Disable cycle diagnostics when used in the type checker.
The type checker has *lots* cycles, and producing diagnostics for them at this point in the development of the request-evaluator is not productive because it breaks currently-working code. Disable cycle diagnostics for now when using the request-evaluator in the type checker. We'll enable it later as things improve, or as a separate logging mode in the interim.
1 parent 2b2e143 commit 9843190

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

include/swift/AST/Evaluator.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class Evaluator {
107107
/// diagnostics will be emitted.
108108
DiagnosticEngine &diags;
109109

110+
/// Whether to diagnose cycles or ignore them completely.
111+
bool shouldDiagnoseCycles;
112+
110113
/// A vector containing all of the active evaluation requests, which
111114
/// is treated as a stack and is used to detect cycles.
112115
llvm::SetVector<AnyRequest> activeRequests;
@@ -128,7 +131,7 @@ class Evaluator {
128131
public:
129132
/// Construct a new evaluator that can emit cyclic-dependency
130133
/// diagnostics through the given diagnostics engine.
131-
Evaluator(DiagnosticEngine &diags);
134+
Evaluator(DiagnosticEngine &diags, bool shouldDiagnoseCycles);
132135

133136
/// Evaluate the given request and produce its result,
134137
/// consulting/populating the cache as required.

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ ASTContext::ASTContext(LangOptions &langOpts, SearchPathOptions &SearchPathOpts,
463463
SearchPathOpts(SearchPathOpts),
464464
SourceMgr(SourceMgr),
465465
Diags(Diags),
466-
evaluator(Diags),
466+
evaluator(Diags, /*shouldDiagnoseCycles=*/false),
467467
TheBuiltinModule(createBuiltinModule(*this)),
468468
StdlibModuleName(getIdentifier(STDLIB_NAME)),
469469
SwiftShimsModuleName(getIdentifier(SWIFT_SHIMS_NAME)),

lib/AST/Evaluator.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ std::string AnyRequest::getAsString() const {
3232
return result;
3333
}
3434

35-
Evaluator::Evaluator(DiagnosticEngine &diags) : diags(diags) { }
35+
Evaluator::Evaluator(DiagnosticEngine &diags, bool shouldDiagnoseCycles)
36+
: diags(diags), shouldDiagnoseCycles(shouldDiagnoseCycles) { }
3637

3738
bool Evaluator::checkDependency(const AnyRequest &request) {
3839
// If there is an active request, record it's dependency on this request.
@@ -44,7 +45,9 @@ bool Evaluator::checkDependency(const AnyRequest &request) {
4445
return false;
4546
}
4647

47-
diagnoseCycle(request);
48+
if (shouldDiagnoseCycles)
49+
diagnoseCycle(request);
50+
4851
return true;
4952
}
5053

unittests/AST/ArithmeticEvaluator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ TEST(ArithmeticEvaluator, Simple) {
200200

201201
SourceManager sourceMgr;
202202
DiagnosticEngine diags(sourceMgr);
203-
Evaluator evaluator(diags);
203+
Evaluator evaluator(diags, /*shouldDiagnoseCycles=*/true);
204204

205205
const double expectedResult = (3.14159 + 2.71828) * 42.0;
206206
EXPECT_EQ(evaluator(InternallyCachedEvaluationRule(product)),
@@ -320,7 +320,7 @@ TEST(ArithmeticEvaluator, Cycle) {
320320

321321
SourceManager sourceMgr;
322322
DiagnosticEngine diags(sourceMgr);
323-
Evaluator evaluator(diags);
323+
Evaluator evaluator(diags, /*shouldDiagnoseCycles=*/true);
324324

325325
// Evaluate when there is a cycle.
326326
UncachedEvaluationRule::brokeCycle = false;

0 commit comments

Comments
 (0)