Skip to content

Commit 5fc1d17

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents b5b0fe6 + bed7f23 commit 5fc1d17

28 files changed

+279
-302
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ struct PrintOptions {
270270
/// Whether to skip keywords with a prefix of underscore such as __consuming.
271271
bool SkipUnderscoredKeywords = false;
272272

273+
/// Prints type variables and unresolved types in an expanded notation suitable
274+
/// for debugging.
275+
bool PrintTypesForDebugging = false;
276+
273277
/// How to print opaque return types.
274278
enum class OpaqueReturnTypePrintingMode {
275279
/// 'some P1 & P2'.

include/swift/Basic/LangOptions.h

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -160,64 +160,19 @@ namespace swift {
160160
/// Flags for developers
161161
///
162162

163-
/// Whether we are debugging the constraint solver.
164-
///
165-
/// This option enables verbose debugging output from the constraint
166-
/// solver.
167-
bool DebugConstraintSolver = false;
168-
169-
/// Specific solution attempt for which the constraint
170-
/// solver should be debugged.
171-
unsigned DebugConstraintSolverAttempt = 0;
172-
173-
/// Line numbers to activate the constraint solver debugger.
174-
/// Should be stored sorted.
175-
llvm::SmallVector<unsigned, 4> DebugConstraintSolverOnLines;
176-
177163
/// Enable named lazy member loading.
178164
bool NamedLazyMemberLoading = true;
179-
180-
/// Debug the generic signatures computed by the generic signature builder.
181-
bool DebugGenericSignatures = false;
182-
183-
/// Triggers llvm fatal_error if typechecker tries to typecheck a decl or an
184-
/// identifier reference with the provided prefix name.
185-
/// This is for testing purposes.
186-
std::string DebugForbidTypecheckPrefix;
187-
188-
/// Whether to dump debug info for request evaluator cycles.
189-
bool DebugDumpCycles = false;
190-
165+
191166
/// The path to which we should emit GraphViz output for the complete
192167
/// request-evaluator graph.
193168
std::string RequestEvaluatorGraphVizPath;
194-
195-
/// The upper bound, in bytes, of temporary data that can be
196-
/// allocated by the constraint solver.
197-
unsigned SolverMemoryThreshold = 512 * 1024 * 1024;
198-
199-
unsigned SolverBindingThreshold = 1024 * 1024;
200-
201-
/// The upper bound to number of sub-expressions unsolved
202-
/// before termination of the shrink phrase of the constraint solver.
203-
unsigned SolverShrinkUnsolvedThreshold = 10;
204-
205-
/// Disable the shrink phase of the expression type checker.
206-
bool SolverDisableShrink = false;
207-
208-
/// Disable constraint system performance hacks.
209-
bool DisableConstraintSolverPerformanceHacks = false;
210-
211-
/// Enable experimental operator designated types feature.
212-
bool EnableOperatorDesignatedTypes = false;
213-
169+
170+
/// Whether to dump debug info for request evaluator cycles.
171+
bool DebugDumpCycles = false;
172+
214173
/// Enable SIL type lowering
215174
bool EnableSubstSILFunctionTypesForFunctionValues = false;
216175

217-
/// Enable constraint solver support for experimental
218-
/// operator protocol designator feature.
219-
bool SolverEnableOperatorDesignatedTypes = false;
220-
221176
/// Whether to diagnose an ephemeral to non-ephemeral conversion as an
222177
/// error.
223178
bool DiagnoseInvalidEphemeralnessAsError = false;
@@ -503,6 +458,55 @@ namespace swift {
503458
/// Indicate that the type checker should skip type-checking non-inlinable
504459
/// function bodies.
505460
bool SkipNonInlinableFunctionBodies = false;
461+
462+
///
463+
/// Flags for developers
464+
///
465+
466+
/// Whether we are debugging the constraint solver.
467+
///
468+
/// This option enables verbose debugging output from the constraint
469+
/// solver.
470+
bool DebugConstraintSolver = false;
471+
472+
/// Specific solution attempt for which the constraint
473+
/// solver should be debugged.
474+
unsigned DebugConstraintSolverAttempt = 0;
475+
476+
/// Line numbers to activate the constraint solver debugger.
477+
/// Should be stored sorted.
478+
llvm::SmallVector<unsigned, 4> DebugConstraintSolverOnLines;
479+
480+
/// Debug the generic signatures computed by the generic signature builder.
481+
bool DebugGenericSignatures = false;
482+
483+
/// Triggers llvm fatal_error if typechecker tries to typecheck a decl or an
484+
/// identifier reference with the provided prefix name.
485+
/// This is for testing purposes.
486+
std::string DebugForbidTypecheckPrefix;
487+
488+
/// The upper bound, in bytes, of temporary data that can be
489+
/// allocated by the constraint solver.
490+
unsigned SolverMemoryThreshold = 512 * 1024 * 1024;
491+
492+
unsigned SolverBindingThreshold = 1024 * 1024;
493+
494+
/// The upper bound to number of sub-expressions unsolved
495+
/// before termination of the shrink phrase of the constraint solver.
496+
unsigned SolverShrinkUnsolvedThreshold = 10;
497+
498+
/// Disable the shrink phase of the expression type checker.
499+
bool SolverDisableShrink = false;
500+
501+
/// Enable experimental operator designated types feature.
502+
bool EnableOperatorDesignatedTypes = false;
503+
504+
/// Disable constraint system performance hacks.
505+
bool DisableConstraintSolverPerformanceHacks = false;
506+
507+
/// Enable constraint solver support for experimental
508+
/// operator protocol designator feature.
509+
bool SolverEnableOperatorDesignatedTypes = false;
506510
};
507511
} // end namespace swift
508512

lib/AST/ASTDumper.cpp

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,15 +1262,6 @@ void ParameterList::dump() const {
12621262
}
12631263

12641264
void ParameterList::dump(raw_ostream &OS, unsigned Indent) const {
1265-
llvm::Optional<llvm::SaveAndRestore<bool>> X;
1266-
1267-
// Make sure to print type variables if we can get to ASTContext.
1268-
if (size() != 0 && get(0)) {
1269-
auto &ctx = get(0)->getASTContext();
1270-
X.emplace(llvm::SaveAndRestore<bool>(ctx.LangOpts.DebugConstraintSolver,
1271-
true));
1272-
}
1273-
12741265
PrintDecl(OS, Indent).printParameterList(this);
12751266
llvm::errs() << '\n';
12761267
}
@@ -1293,9 +1284,6 @@ void Decl::dump(const char *filename) const {
12931284
}
12941285

12951286
void Decl::dump(raw_ostream &OS, unsigned Indent) const {
1296-
// Make sure to print type variables.
1297-
llvm::SaveAndRestore<bool> X(getASTContext().LangOpts.DebugConstraintSolver,
1298-
true);
12991287
PrintDecl(OS, Indent).visit(const_cast<Decl *>(this));
13001288
OS << '\n';
13011289
}
@@ -1407,8 +1395,6 @@ void SourceFile::dump() const {
14071395
}
14081396

14091397
void SourceFile::dump(llvm::raw_ostream &OS) const {
1410-
llvm::SaveAndRestore<bool> X(getASTContext().LangOpts.DebugConstraintSolver,
1411-
true);
14121398
PrintDecl(OS).visitSourceFile(*this);
14131399
llvm::errs() << '\n';
14141400
}
@@ -1826,13 +1812,17 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18261812
}
18271813

18281814
raw_ostream &printCommon(Expr *E, const char *C) {
1815+
PrintOptions PO;
1816+
PO.PrintTypesForDebugging = true;
1817+
18291818
OS.indent(Indent);
18301819
PrintWithColorRAII(OS, ParenthesisColor) << '(';
18311820
PrintWithColorRAII(OS, ExprColor) << C;
18321821

18331822
if (E->isImplicit())
18341823
PrintWithColorRAII(OS, ExprModifierColor) << " implicit";
1835-
PrintWithColorRAII(OS, TypeColor) << " type='" << GetTypeOfExpr(E) << '\'';
1824+
PrintWithColorRAII(OS, TypeColor) << " type='";
1825+
PrintWithColorRAII(OS, TypeColor) << GetTypeOfExpr(E).getString(PO) << '\'';
18361826

18371827
// If we have a source range and an ASTContext, print the source range.
18381828
if (auto Ty = GetTypeOfExpr(E)) {
@@ -3749,14 +3739,10 @@ namespace {
37493739
} // end anonymous namespace
37503740

37513741
void Type::dump() const {
3752-
// Make sure to print type variables.
37533742
dump(llvm::errs());
37543743
}
37553744

37563745
void Type::dump(raw_ostream &os, unsigned indent) const {
3757-
// Make sure to print type variables.
3758-
llvm::SaveAndRestore<bool> X(getPointer()->getASTContext().LangOpts.
3759-
DebugConstraintSolver, true);
37603746
PrintType(os, indent).visit(*this, "");
37613747
os << "\n";
37623748
}
@@ -3767,10 +3753,6 @@ void TypeBase::dump() const {
37673753
}
37683754

37693755
void TypeBase::dump(raw_ostream &os, unsigned indent) const {
3770-
auto &ctx = const_cast<TypeBase*>(this)->getASTContext();
3771-
3772-
// Make sure to print type variables.
3773-
llvm::SaveAndRestore<bool> X(ctx.LangOpts.DebugConstraintSolver, true);
37743756
Type(const_cast<TypeBase *>(this)).dump(os, indent);
37753757
}
37763758

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,7 +3595,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
35953595
}
35963596

35973597
void visitUnresolvedType(UnresolvedType *T) {
3598-
if (T->getASTContext().LangOpts.DebugConstraintSolver)
3598+
if (Options.PrintTypesForDebugging)
35993599
Printer << "<<unresolvedtype>>";
36003600
else
36013601
Printer << "_";
@@ -4331,7 +4331,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
43314331
#include "swift/AST/ReferenceStorage.def"
43324332

43334333
void visitTypeVariableType(TypeVariableType *T) {
4334-
if (T->getASTContext().LangOpts.DebugConstraintSolver) {
4334+
if (Options.PrintTypesForDebugging) {
43354335
Printer << "$T" << T->getID();
43364336
return;
43374337
}

0 commit comments

Comments
 (0)