Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / tools / clang / blink_gc_plugin / CheckFieldsVisitor.h
blobe0c36a2d89d128849e2588362e80b0d8e2ae4ebc
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 #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
6 #define TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
8 #include <vector>
10 #include "Edge.h"
12 struct BlinkGCPluginOptions;
13 class FieldPoint;
15 // This visitor checks that the fields of a class are "well formed".
16 // - OwnPtr, RefPtr and RawPtr must not point to a GC derived types.
17 // - Part objects must not be GC derived types.
18 // - An on-heap class must never contain GC roots.
19 // - Only stack-allocated types may point to stack-allocated types.
21 class CheckFieldsVisitor : public RecursiveEdgeVisitor {
22 public:
23 enum Error {
24 kRawPtrToGCManaged,
25 kRawPtrToGCManagedWarning,
26 kRefPtrToGCManaged,
27 kReferencePtrToGCManaged,
28 kReferencePtrToGCManagedWarning,
29 kOwnPtrToGCManaged,
30 kMemberToGCUnmanaged,
31 kMemberInUnmanaged,
32 kPtrFromHeapToStack,
33 kGCDerivedPartObject
36 typedef std::vector<std::pair<FieldPoint*, Error> > Errors;
38 explicit CheckFieldsVisitor(const BlinkGCPluginOptions& options);
40 Errors& invalid_fields();
42 bool ContainsInvalidFields(RecordInfo* info);
44 void AtMember(Member* edge) override;
45 void AtValue(Value* edge) override;
46 void AtCollection(Collection* edge) override;
48 static bool IsWarning(Error error);
49 static bool IsRawPtrError(Error error);
50 static bool IsReferencePtrError(Error error);
52 private:
53 Error InvalidSmartPtr(Edge* ptr);
55 const BlinkGCPluginOptions& options_;
56 FieldPoint* current_;
57 bool stack_allocated_host_;
58 bool managed_host_;
59 Errors invalid_fields_;
62 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_