Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / tools / clang / blink_gc_plugin / CheckGCRootsVisitor.cpp
blobab2d2601bc3e527a39e144b1b0d6ccb022a4f7de
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "CheckGCRootsVisitor.h"
7 CheckGCRootsVisitor::CheckGCRootsVisitor() {
10 CheckGCRootsVisitor::Errors& CheckGCRootsVisitor::gc_roots() {
11 return gc_roots_;
14 bool CheckGCRootsVisitor::ContainsGCRoots(RecordInfo* info) {
15 for (RecordInfo::Fields::iterator it = info->GetFields().begin();
16 it != info->GetFields().end();
17 ++it) {
18 current_.push_back(&it->second);
19 it->second.edge()->Accept(this);
20 current_.pop_back();
22 return !gc_roots_.empty();
25 void CheckGCRootsVisitor::VisitValue(Value* edge) {
26 // TODO: what should we do to check unions?
27 if (edge->value()->record()->isUnion())
28 return;
30 // Prevent infinite regress for cyclic part objects.
31 if (visiting_set_.find(edge->value()) != visiting_set_.end())
32 return;
34 visiting_set_.insert(edge->value());
35 // If the value is a part object, then continue checking for roots.
36 for (Context::iterator it = context().begin();
37 it != context().end();
38 ++it) {
39 if (!(*it)->IsCollection())
40 return;
42 ContainsGCRoots(edge->value());
43 visiting_set_.erase(edge->value());
46 void CheckGCRootsVisitor::VisitPersistent(Persistent* edge) {
47 gc_roots_.push_back(current_);
50 void CheckGCRootsVisitor::AtCollection(Collection* edge) {
51 if (edge->is_root())
52 gc_roots_.push_back(current_);