Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: tools/clang/blink_gc_plugin/CheckFieldsVisitor.h

Issue 2902563002: blink_gc_plugin: disallow WeakMember<> fields in off-heap objects. (Closed)
Patch Set: add missing file from ps#3 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_ 5 #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
6 #define TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_ 6 #define TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "BlinkGCPluginOptions.h"
10 #include "Edge.h" 11 #include "Edge.h"
11 12
12 class FieldPoint; 13 class FieldPoint;
13 14
14 // This visitor checks that the fields of a class are "well formed". 15 // This visitor checks that the fields of a class are "well formed".
15 // - OwnPtr and RefPtr must not point to a GC derived type. 16 // - OwnPtr and RefPtr must not point to a GC derived type.
16 // - Part objects must not be a GC derived type. 17 // - Part objects must not be a GC derived type.
17 // - An on-heap class must never contain GC roots. 18 // - An on-heap class must never contain GC roots.
18 // - Only stack-allocated types may point to stack-allocated types. 19 // - Only stack-allocated types may point to stack-allocated types.
19 20
20 class CheckFieldsVisitor : public RecursiveEdgeVisitor { 21 class CheckFieldsVisitor : public RecursiveEdgeVisitor {
21 public: 22 public:
22 enum Error { 23 enum Error {
23 kRawPtrToGCManaged, 24 kRawPtrToGCManaged,
24 kRefPtrToGCManaged, 25 kRefPtrToGCManaged,
25 kReferencePtrToGCManaged, 26 kReferencePtrToGCManaged,
26 kOwnPtrToGCManaged, 27 kOwnPtrToGCManaged,
27 kUniquePtrToGCManaged, 28 kUniquePtrToGCManaged,
28 kMemberToGCUnmanaged, 29 kMemberToGCUnmanaged,
29 kMemberInUnmanaged, 30 kMemberInUnmanaged,
30 kPtrFromHeapToStack, 31 kPtrFromHeapToStack,
31 kGCDerivedPartObject, 32 kGCDerivedPartObject,
32 kIteratorToGCManaged, 33 kIteratorToGCManaged,
33 }; 34 };
34 35
35 using Errors = std::vector<std::pair<FieldPoint*, Error>>; 36 using Errors = std::vector<std::pair<FieldPoint*, Error>>;
36 37
37 CheckFieldsVisitor(); 38 explicit CheckFieldsVisitor(const BlinkGCPluginOptions&);
38 39
39 Errors& invalid_fields(); 40 Errors& invalid_fields();
40 41
41 bool ContainsInvalidFields(RecordInfo* info); 42 bool ContainsInvalidFields(RecordInfo* info);
42 43
43 void AtMember(Member* edge) override; 44 void AtMember(Member*) override;
44 void AtValue(Value* edge) override; 45 void AtWeakMember(WeakMember*) override;
45 void AtCollection(Collection* edge) override; 46 void AtValue(Value*) override;
47 void AtCollection(Collection*) override;
46 void AtIterator(Iterator*) override; 48 void AtIterator(Iterator*) override;
47 49
48 private: 50 private:
49 Error InvalidSmartPtr(Edge* ptr); 51 Error InvalidSmartPtr(Edge* ptr);
50 52
53 const BlinkGCPluginOptions& options_;
54
51 FieldPoint* current_; 55 FieldPoint* current_;
52 bool stack_allocated_host_; 56 bool stack_allocated_host_;
53 bool managed_host_; 57 bool managed_host_;
54 Errors invalid_fields_; 58 Errors invalid_fields_;
55 }; 59 };
56 60
57 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_ 61 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/BlinkGCPluginOptions.h ('k') | tools/clang/blink_gc_plugin/CheckFieldsVisitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698