blob: 2887bae894d5c52cfeb72544a298ad616c0404cb [file] [log] [blame]
yutak4d2f1c7f2015-09-16 10:29:361// 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.
4
5#ifndef TOOLS_BLINK_GC_PLUGIN_BLINK_GC_PLUGIN_OPTIONS_H_
6#define TOOLS_BLINK_GC_PLUGIN_BLINK_GC_PLUGIN_OPTIONS_H_
7
8#include <set>
9#include <string>
10#include <vector>
11
12struct BlinkGCPluginOptions {
Daniel Cheng2de974ba2016-12-20 22:15:1313 bool dump_graph = false;
sigbjornf59dc1fe2017-02-08 18:49:4314
sigbjornf55a04e9c2017-05-24 18:37:2315 // Member<T> fields are only permitted in managed classes,
16 // something CheckFieldsVisitor verifies, issuing errors if
17 // found in unmanaged classes. WeakMember<T> should be treated
18 // the exact same, but CheckFieldsVisitor was missing the case
19 // for handling the weak member variant until crbug.com/724418.
20 //
21 // We've default-enabled the checking for those also now, but do
22 // offer an opt-out option should enabling the check lead to
23 // unexpected (but wanted, really) compilation errors while
24 // rolling out an updated GC plugin version.
25 //
26 // TODO(sof): remove this option once safely rolled out.
27 bool enable_weak_members_in_unmanaged_classes = false;
28
Omer Katzf155ae12022-01-05 17:46:3929 // Persistent<T> fields are not allowed in garbage collected classes to avoid
30 // memory leaks. Enabling this flag allows the plugin to check also for
31 // Persistent<T> in types held by unique_ptr in garbage collected classes. The
32 // guideline for this check is that a Persistent<T> should never be kept alive
33 // by a garbage collected class, which unique_ptr clearly conveys.
34 //
35 // This check is disabled by default since there are currently non-ignored
36 // violations of this rule in the code base, leading to compilation failures.
37 // TODO(chromium:1283867): Enable this checks once all violations are handled.
38 bool enable_persistent_in_unique_ptr_check = false;
39
Omer Katzddfccc52022-01-20 18:08:3440 // On stack references to garbage collected objects should use raw pointers.
41 // Although using Members/WeakMembers on stack is not strictly incorrect, it
42 // is redundant and incurs additional costs that can mount up and become
43 // significant. Enabling this flag lets the plugin to check for instances of
44 // using Member/WeakMember on stack. These would include variable
45 // declarations, method arguments and return types.
46 //
47 // This check is disabled by default since there currently are violations
48 // of this rule in the code base, leading to compilation failures.
49 // TODO(chromium:1283720): Enable this checks once all violations are handled.
50 bool enable_members_on_stack_check = false;
51
yutak4d2f1c7f2015-09-16 10:29:3652 std::set<std::string> ignored_classes;
53 std::set<std::string> checked_namespaces;
54 std::vector<std::string> ignored_directories;
Omer Katzc11c1612020-06-18 22:31:2555 // |allowed_directories| overrides |ignored_directories|.
56 std::vector<std::string> allowed_directories;
yutak4d2f1c7f2015-09-16 10:29:3657};
58
59#endif // TOOLS_BLINK_GC_PLUGIN_BLINK_GC_PLUGIN_OPTIONS_H_