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

Unified Diff: tools/clang/blink_gc_plugin/CheckFieldsVisitor.h

Issue 1385193002: Bisect clang Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 246985 Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: tools/clang/blink_gc_plugin/CheckFieldsVisitor.h
diff --git a/tools/clang/blink_gc_plugin/CheckFieldsVisitor.h b/tools/clang/blink_gc_plugin/CheckFieldsVisitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..e0c36a2d89d128849e2588362e80b0d8e2ae4ebc
--- /dev/null
+++ b/tools/clang/blink_gc_plugin/CheckFieldsVisitor.h
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
+#define TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
+
+#include <vector>
+
+#include "Edge.h"
+
+struct BlinkGCPluginOptions;
+class FieldPoint;
+
+// This visitor checks that the fields of a class are "well formed".
+// - OwnPtr, RefPtr and RawPtr must not point to a GC derived types.
+// - Part objects must not be GC derived types.
+// - An on-heap class must never contain GC roots.
+// - Only stack-allocated types may point to stack-allocated types.
+
+class CheckFieldsVisitor : public RecursiveEdgeVisitor {
+ public:
+ enum Error {
+ kRawPtrToGCManaged,
+ kRawPtrToGCManagedWarning,
+ kRefPtrToGCManaged,
+ kReferencePtrToGCManaged,
+ kReferencePtrToGCManagedWarning,
+ kOwnPtrToGCManaged,
+ kMemberToGCUnmanaged,
+ kMemberInUnmanaged,
+ kPtrFromHeapToStack,
+ kGCDerivedPartObject
+ };
+
+ typedef std::vector<std::pair<FieldPoint*, Error> > Errors;
+
+ explicit CheckFieldsVisitor(const BlinkGCPluginOptions& options);
+
+ Errors& invalid_fields();
+
+ bool ContainsInvalidFields(RecordInfo* info);
+
+ void AtMember(Member* edge) override;
+ void AtValue(Value* edge) override;
+ void AtCollection(Collection* edge) override;
+
+ static bool IsWarning(Error error);
+ static bool IsRawPtrError(Error error);
+ static bool IsReferencePtrError(Error error);
+
+ private:
+ Error InvalidSmartPtr(Edge* ptr);
+
+ const BlinkGCPluginOptions& options_;
+ FieldPoint* current_;
+ bool stack_allocated_host_;
+ bool managed_host_;
+ Errors invalid_fields_;
+};
+
+#endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FIELDS_VISITOR_H_
« no previous file with comments | « tools/clang/blink_gc_plugin/CheckDispatchVisitor.cpp ('k') | tools/clang/blink_gc_plugin/CheckFieldsVisitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698