31 #ifndef GOOGLE_PROTOBUF_COMPILER_SCC_H__
32 #define GOOGLE_PROTOBUF_COMPILER_SCC_H__
40 #include <google/protobuf/port_def.inc>
62 template <
class DepsGenerator>
79 std::map<const Descriptor*, NodeData>
cache_;
80 std::vector<const Descriptor*>
stack_;
85 garbage_bin_.emplace_back(
new SCC());
86 return garbage_bin_.back().get();
97 result.index = result.lowlink =
index_++;
101 for (
auto dep : DepsGenerator()(
descriptor)) {
103 if (cache_.count(dep) == 0) {
105 NodeData child_data = DFS(dep);
106 result.lowlink = std::min(result.lowlink, child_data.lowlink);
108 NodeData child_data = cache_[dep];
109 if (child_data.scc ==
nullptr) {
111 result.lowlink = std::min(result.lowlink, child_data.index);
115 if (result.index == result.lowlink) {
117 SCC* scc = CreateSCC();
123 cache_[scc_desc].scc = scc;
132 return a->full_name() < b->full_name();
141 std::set<const SCC*> seen;
143 for (
auto child_msg : DepsGenerator()(
descriptor)) {
145 const SCC*
child = GetSCC(child_msg);
146 if (
child == scc)
continue;
147 if (seen.insert(
child).second) {
162 #include <google/protobuf/port_undef.inc>
164 #endif // GOOGLE_PROTOBUF_COMPILER_SCC_H__