blob: 03a5b377ad8cb9dfda6ecafbdf9ccd6330c73afb [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:091// Copyright 2015 The Chromium Authors
yutak41e9c2d2015-09-18 14:37:432// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_GC_ROOTS_VISITOR_H_
6#define TOOLS_BLINK_GC_PLUGIN_CHECK_GC_ROOTS_VISITOR_H_
7
8#include <set>
9#include <vector>
10
11#include "Edge.h"
12#include "RecordInfo.h"
13
Omer Katzf155ae12022-01-05 17:46:3914struct BlinkGCPluginOptions;
15
yutak41e9c2d2015-09-18 14:37:4316// This visitor checks that the fields of a class and the fields of
17// its part objects don't define GC roots.
18class CheckGCRootsVisitor : public RecursiveEdgeVisitor {
19 public:
20 typedef std::vector<FieldPoint*> RootPath;
21 typedef std::set<RecordInfo*> VisitingSet;
22 typedef std::vector<RootPath> Errors;
23
Omer Katzf155ae12022-01-05 17:46:3924 explicit CheckGCRootsVisitor(const BlinkGCPluginOptions&);
yutak41e9c2d2015-09-18 14:37:4325
26 Errors& gc_roots();
Omer Katz550795dfe2023-06-09 09:50:5627 Errors& gc_root_refs();
yutak41e9c2d2015-09-18 14:37:4328
29 bool ContainsGCRoots(RecordInfo* info);
30
31 void VisitValue(Value* edge) override;
Omer Katzf155ae12022-01-05 17:46:3932 void VisitUniquePtr(UniquePtr*) override;
Omer Katz550795dfe2023-06-09 09:50:5633 void VisitRawPtr(RawPtr*) override;
34 void VisitRefPtr(RefPtr*) override;
yutak41e9c2d2015-09-18 14:37:4335 void VisitPersistent(Persistent* edge) override;
Paul Semel1fd727f2023-01-05 10:31:3836 void VisitCollection(Collection* edge) override;
yutak41e9c2d2015-09-18 14:37:4337
38 private:
39 RootPath current_;
40 VisitingSet visiting_set_;
41 Errors gc_roots_;
Omer Katz550795dfe2023-06-09 09:50:5642 Errors gc_root_refs_;
43 bool is_ref_ = false;
Omer Katzf155ae12022-01-05 17:46:3944
45 bool should_check_unique_ptrs_;
yutak41e9c2d2015-09-18 14:37:4346};
47
48#endif // TOOLS_BLINK_GC_PLUGIN_CHECK_GC_ROOTS_VISITOR_H_