Skip to content

Commit edca0c1

Browse files
committed
---
yaml --- r: 326585 b: refs/heads/tensorflow c: f19016b h: refs/heads/master i: 326583: 623179c
1 parent 90863ae commit edca0c1

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: 0b7ef3445eeda7fbe29c0edc91aebc1a846a7755
819+
refs/heads/tensorflow: f19016b94b0f0b8ed2fff8c0d3316504402bc21c
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/lib/Sema/ConstraintGraph.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -814,19 +814,29 @@ namespace {
814814
}
815815

816816
/// Perform a depth-first search to produce a from the given type variable,
817-
/// notifying the function object \c postVisit after each reachable
818-
/// type variable has been visited.
817+
/// notifying the function object.
818+
///
819+
/// \param getAdjacencies Called to retrieve the set of type variables
820+
/// that are adjacent to the given type variable.
821+
///
822+
/// \param preVisit Called before visiting the adjacencies of the given
823+
/// type variable. When it returns \c true, the adjacencies of this type
824+
/// variable will be visited. When \c false, the adjacencies will not be
825+
/// visited and \c postVisit will not be called.
826+
///
827+
/// \param postVisit Called after visiting the adjacencies of the given
828+
/// type variable.
819829
static void postorderDepthFirstSearchRec(
820830
TypeVariableType *typeVar,
821831
llvm::function_ref<
822832
ArrayRef<TypeVariableType *>(TypeVariableType *)> getAdjacencies,
823-
llvm::function_ref<void(TypeVariableType *)> postVisit,
824-
SmallPtrSet<TypeVariableType *, 4> &visited) {
825-
if (!visited.insert(typeVar).second)
833+
llvm::function_ref<bool(TypeVariableType *)> preVisit,
834+
llvm::function_ref<void(TypeVariableType *)> postVisit) {
835+
if (!preVisit(typeVar))
826836
return;
827837

828838
for (auto adj : getAdjacencies(typeVar)) {
829-
postorderDepthFirstSearchRec(adj, getAdjacencies, postVisit, visited);
839+
postorderDepthFirstSearchRec(adj, getAdjacencies, preVisit, postVisit);
830840
}
831841

832842
postVisit(typeVar);
@@ -855,14 +865,16 @@ namespace {
855865

856866
return oneWayComponent->second.inAdjacencies;
857867
},
868+
[&](TypeVariableType *typeVar) {
869+
return visited.insert(typeVar).second;
870+
},
858871
[&](TypeVariableType *dependsOn) {
859872
// Don't record dependency on ourselves.
860873
if (dependsOn == inAdj)
861874
return;
862875

863876
indirectlyReachable.insert(dependsOn);
864-
},
865-
visited);
877+
});
866878

867879
// Remove any in-adjacency of this component that is indirectly
868880
// reachable.
@@ -922,13 +934,15 @@ namespace {
922934

923935
return oneWayComponent->second.outAdjacencies;
924936
},
937+
[&](TypeVariableType *typeVar) {
938+
return visited.insert(typeVar).second;
939+
},
925940
[&](TypeVariableType *typeVar) {
926941
// Record this type variable, if it's one of the representative
927942
// type variables.
928943
if (validComponents.count(typeVar) > 0)
929944
orderedReps.push_back(typeVar);
930-
},
931-
visited);
945+
});
932946
}
933947

934948
assert(orderedReps.size() == representativeTypeVars.size());

0 commit comments

Comments
 (0)