yutak | 4d2f1c7f | 2015-09-16 10:29:36 | [diff] [blame] | 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. |
| 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 | |
| 12 | struct BlinkGCPluginOptions { |
Daniel Cheng | 2de974ba | 2016-12-20 22:15:13 | [diff] [blame] | 13 | bool dump_graph = false; |
sigbjornf | 59dc1fe | 2017-02-08 18:49:43 | [diff] [blame] | 14 | |
sigbjornf | 55a04e9c | 2017-05-24 18:37:23 | [diff] [blame] | 15 | // 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 Katz | f155ae1 | 2022-01-05 17:46:39 | [diff] [blame] | 29 | // 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 Katz | ddfccc5 | 2022-01-20 18:08:34 | [diff] [blame^] | 40 | // 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 | |
yutak | 4d2f1c7f | 2015-09-16 10:29:36 | [diff] [blame] | 52 | std::set<std::string> ignored_classes; |
| 53 | std::set<std::string> checked_namespaces; |
| 54 | std::vector<std::string> ignored_directories; |
Omer Katz | c11c161 | 2020-06-18 22:31:25 | [diff] [blame] | 55 | // |allowed_directories| overrides |ignored_directories|. |
| 56 | std::vector<std::string> allowed_directories; |
yutak | 4d2f1c7f | 2015-09-16 10:29:36 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | #endif // TOOLS_BLINK_GC_PLUGIN_BLINK_GC_PLUGIN_OPTIONS_H_ |