Skip to content

Commit 0a55516

Browse files
committed
Use PrintOptions::forDebugging in a few more places
Use for a few `dump` methods, generic signature debugging, and enable by default for swift-ide-test.
1 parent 14a125c commit 0a55516

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6820,7 +6820,7 @@ void RequirementRepr::dump() const {
68206820
}
68216821

68226822
void GenericParamList::dump() const {
6823-
print(llvm::errs());
6823+
print(llvm::errs(), PrintOptions::forDebugging());
68246824
llvm::errs() << '\n';
68256825
}
68266826

@@ -6829,11 +6829,11 @@ void LayoutConstraint::dump() const {
68296829
llvm::errs() << "(null)\n";
68306830
return;
68316831
}
6832-
getPointer()->print(llvm::errs());
6832+
getPointer()->print(llvm::errs(), PrintOptions::forDebugging());
68336833
}
68346834

68356835
void GenericSignature::dump() const {
6836-
print(llvm::errs());
6836+
print(llvm::errs(), PrintOptions::forDebugging());
68376837
llvm::errs() << '\n';
68386838
}
68396839

@@ -6868,7 +6868,7 @@ void InheritedEntry::dump(llvm::raw_ostream &os) const {
68686868
os << '@' << getDumpString(getExplicitSafety()) << ' ';
68696869
if (isSuppressed())
68706870
os << "~";
6871-
getType().print(os);
6871+
getType().print(os, PrintOptions::forDebugging());
68726872
}
68736873

68746874
void InheritedEntry::dump() const { dump(llvm::errs()); }

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ static void dumpGenericSignature(ASTContext &ctx, GenericContext *GC) {
20552055
GC->printContext(llvm::errs());
20562056
}
20572057
llvm::errs() << "Generic signature: ";
2058-
PrintOptions Opts;
2058+
PrintOptions Opts = PrintOptions::forDebugging();
20592059
Opts.ProtocolQualifiedDependentMemberTypes = true;
20602060
Opts.PrintInverseRequirements =
20612061
!ctx.TypeCheckerOpts.DebugInverseRequirements;
@@ -3427,7 +3427,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
34273427
PD->dumpRef(llvm::errs());
34283428
llvm::errs() << "\n";
34293429
llvm::errs() << "Requirement signature: ";
3430-
PrintOptions Opts;
3430+
PrintOptions Opts = PrintOptions::forDebugging();
34313431
Opts.ProtocolQualifiedDependentMemberTypes = true;
34323432
Opts.PrintInverseRequirements =
34333433
!Ctx.TypeCheckerOpts.DebugInverseRequirements;

test/Generics/parameter-pack-requirements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protocol PP {
117117
struct G<each T> {}
118118

119119
// CHECK-LABEL: sameTypeMatch1
120-
// CHECK-NEXT: <T, each U, each V where T : PP, repeat each U : PP, repeat each V : PP, T.[PP]A == G<repeat (each U).[PP]A>, repeat (each U).[PP]A == (each V).[PP]A>
120+
// CHECK-NEXT: <T, each U, each V where T : PP, repeat each U : PP, repeat each V : PP, T.[PP]A == G<Pack{repeat (each U).[PP]A}>, repeat (each U).[PP]A == (each V).[PP]A>
121121
func sameTypeMatch1<T: PP, each U: PP, each V: PP>(t: T, u: repeat each U, v: repeat each V)
122122
where T.A == G<repeat (each U).A>, T.A == G<repeat (each V).A>,
123123
(repeat (each U, each V)) : Any {}

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@ PreferTypeRepr("prefer-type-repr",
585585
llvm::cl::cat(Category),
586586
llvm::cl::init(true));
587587

588+
static llvm::cl::opt<bool> PrintForDebugging(
589+
"debug-print",
590+
llvm::cl::desc("Print using the debug representation for types"),
591+
llvm::cl::cat(Category), llvm::cl::init(true));
592+
588593
static llvm::cl::opt<bool>
589594
FullyQualifiedTypes("fully-qualified-types",
590595
llvm::cl::desc("Print fully qualified types"),
@@ -4735,6 +4740,7 @@ int main(int argc, char *argv[]) {
47354740
return PrintOptions::printDocInterface();
47364741
} else {
47374742
auto PrintOpts = PrintOptions::printEverything();
4743+
PrintOpts.PrintTypesForDebugging = options::PrintForDebugging;
47384744
PrintOpts.FullyQualifiedTypes = options::FullyQualifiedTypes;
47394745
PrintOpts.FullyQualifiedTypesIfAmbiguous =
47404746
options::FullyQualifiedTypesIfAmbiguous;

0 commit comments

Comments
 (0)