Skip to content

Commit eaafa04

Browse files
committed
[Constraint graph] Print only those type variables that are of interest now
(cherry picked from commit c2a9286)
1 parent cf0ac49 commit eaafa04

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

lib/Sema/CSStep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ void SplitterStep::computeFollowupSteps(
123123
CG.verify();
124124

125125
log << "---Constraint graph---\n";
126-
CG.print(log);
126+
CG.print(CS.TypeVariables, log);
127127

128128
log << "---Connected components---\n";
129-
CG.printConnectedComponents(log);
129+
CG.printConnectedComponents(CS.TypeVariables, log);
130130
}
131131

132132
// Map type variables and constraints into appropriate steps.

lib/Sema/ConstraintGraph.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -791,22 +791,29 @@ void ConstraintGraphNode::dump() {
791791
print(llvm::dbgs(), 0);
792792
}
793793

794-
void ConstraintGraph::print(llvm::raw_ostream &out) {
795-
for (auto typeVar : TypeVariables) {
794+
void ConstraintGraph::print(ArrayRef<TypeVariableType *> typeVars,
795+
llvm::raw_ostream &out) {
796+
for (auto typeVar : typeVars) {
796797
(*this)[typeVar].print(out, 2);
797798
out << "\n";
798799
}
799800
}
800801

801802
void ConstraintGraph::dump() {
803+
dump(llvm::dbgs());
804+
}
805+
806+
void ConstraintGraph::dump(llvm::raw_ostream &out) {
802807
llvm::SaveAndRestore<bool>
803808
debug(CS.getASTContext().LangOpts.DebugConstraintSolver, true);
804-
print(llvm::dbgs());
809+
print(CS.TypeVariables, out);
805810
}
806811

807-
void ConstraintGraph::printConnectedComponents(llvm::raw_ostream &out) {
812+
void ConstraintGraph::printConnectedComponents(
813+
ArrayRef<TypeVariableType *> inTypeVars,
814+
llvm::raw_ostream &out) {
808815
std::vector<TypeVariableType *> typeVars;
809-
typeVars.insert(typeVars.end(), TypeVariables.begin(), TypeVariables.end());
816+
typeVars.insert(typeVars.end(), inTypeVars.begin(), inTypeVars.end());
810817
std::vector<unsigned> components;
811818
unsigned numComponents = computeConnectedComponents(typeVars, components);
812819
for (unsigned component = 0; component != numComponents; ++component) {
@@ -823,7 +830,7 @@ void ConstraintGraph::printConnectedComponents(llvm::raw_ostream &out) {
823830
}
824831

825832
void ConstraintGraph::dumpConnectedComponents() {
826-
printConnectedComponents(llvm::dbgs());
833+
printConnectedComponents(CS.TypeVariables, llvm::dbgs());
827834
}
828835

829836
#pragma mark Verification of graph invariants
@@ -856,7 +863,7 @@ static void _require(bool condition, const Twine &complaint,
856863

857864
// Print the graph.
858865
// FIXME: Highlight the offending node/constraint/etc.
859-
cg.print(llvm::dbgs());
866+
cg.dump(llvm::dbgs());
860867

861868
abort();
862869
}

lib/Sema/ConstraintGraph.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,15 @@ class ConstraintGraph {
246246
}
247247

248248
/// Print the graph.
249-
void print(llvm::raw_ostream &out);
249+
void print(ArrayRef<TypeVariableType *> typeVars, llvm::raw_ostream &out);
250+
void dump(llvm::raw_ostream &out);
250251

251252
LLVM_ATTRIBUTE_DEPRECATED(void dump() LLVM_ATTRIBUTE_USED,
252253
"only for use within the debugger");
253254

254255
/// Print the connected components of the graph.
255-
void printConnectedComponents(llvm::raw_ostream &out);
256+
void printConnectedComponents(ArrayRef<TypeVariableType *> typeVars,
257+
llvm::raw_ostream &out);
256258

257259
LLVM_ATTRIBUTE_DEPRECATED(void dumpConnectedComponents() LLVM_ATTRIBUTE_USED,
258260
"only for use within the debugger");

0 commit comments

Comments
 (0)