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

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

Issue 2060553002: GC plugin: improve error reporting when tracing illegal fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: robustify namespace equality checking instead Created 4 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 "Edge.h" 10 #include "Edge.h"
11 11
12 struct BlinkGCPluginOptions; 12 struct BlinkGCPluginOptions;
13 class FieldPoint; 13 class FieldPoint;
14 14
15 // 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".
16 // - OwnPtr and RefPtr must not point to a GC derived type. 16 // - OwnPtr and RefPtr must not point to a GC derived type.
17 // - Part objects must not be a GC derived type. 17 // - Part objects must not be a GC derived type.
18 // - An on-heap class must never contain GC roots. 18 // - An on-heap class must never contain GC roots.
19 // - Only stack-allocated types may point to stack-allocated types. 19 // - Only stack-allocated types may point to stack-allocated types.
20 20
21 class CheckFieldsVisitor : public RecursiveEdgeVisitor { 21 class CheckFieldsVisitor : public RecursiveEdgeVisitor {
22 public: 22 public:
23 enum Error { 23 enum Error {
24 kRawPtrToGCManaged, 24 kRawPtrToGCManaged,
25 kRefPtrToGCManaged, 25 kRefPtrToGCManaged,
26 kReferencePtrToGCManaged, 26 kReferencePtrToGCManaged,
27 kOwnPtrToGCManaged, 27 kOwnPtrToGCManaged,
28 kUniquePtrToGCManaged,
28 kMemberToGCUnmanaged, 29 kMemberToGCUnmanaged,
29 kMemberInUnmanaged, 30 kMemberInUnmanaged,
30 kPtrFromHeapToStack, 31 kPtrFromHeapToStack,
31 kGCDerivedPartObject 32 kGCDerivedPartObject
32 }; 33 };
33 34
34 using Errors = std::vector<std::pair<FieldPoint*, Error>>; 35 using Errors = std::vector<std::pair<FieldPoint*, Error>>;
35 36
36 CheckFieldsVisitor(); 37 CheckFieldsVisitor();
37 38
38 Errors& invalid_fields(); 39 Errors& invalid_fields();
39 40
40 bool ContainsInvalidFields(RecordInfo* info); 41 bool ContainsInvalidFields(RecordInfo* info);
41 42
42 void AtMember(Member* edge) override; 43 void AtMember(Member* edge) override;
43 void AtValue(Value* edge) override; 44 void AtValue(Value* edge) override;
44 void AtCollection(Collection* edge) override; 45 void AtCollection(Collection* edge) override;
45 46
46 private: 47 private:
47 Error InvalidSmartPtr(Edge* ptr); 48 Error InvalidSmartPtr(Edge* ptr);
48 49
49 FieldPoint* current_; 50 FieldPoint* current_;
50 bool stack_allocated_host_; 51 bool stack_allocated_host_;
51 bool managed_host_; 52 bool managed_host_;
52 Errors invalid_fields_; 53 Errors invalid_fields_;
53 }; 54 };
54 55
55 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_ 56 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp ('k') | tools/clang/blink_gc_plugin/CheckFieldsVisitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698