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

Unified Diff: tools/clang/blink_gc_plugin/CheckFinalizerVisitor.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/CheckFinalizerVisitor.h
diff --git a/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.h b/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..f926a0d14b0c19e396e249fda40f207ab9fa8e88
--- /dev/null
+++ b/tools/clang/blink_gc_plugin/CheckFinalizerVisitor.h
@@ -0,0 +1,57 @@
+// 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_FINALIZER_VISITOR_H_
+#define TOOLS_BLINK_GC_PLUGIN_CHECK_FINALIZER_VISITOR_H_
+
+#include <set>
+#include <vector>
+
+#include "Edge.h"
+#include "RecordInfo.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+
+// This visitor checks that a finalizer method does not have invalid access to
+// fields that are potentially finalized. A potentially finalized field is
+// either a Member, a heap-allocated collection or an off-heap collection that
+// contains Members. Invalid uses are currently identified as passing the field
+// as the argument of a procedure call or using the -> or [] operators on it.
+class CheckFinalizerVisitor
+ : public clang::RecursiveASTVisitor<CheckFinalizerVisitor> {
+ public:
+ struct Error {
+ Error(clang::MemberExpr* member,
+ bool as_eagerly_finalized,
+ FieldPoint* field)
+ : member(member),
+ as_eagerly_finalized(as_eagerly_finalized),
+ field(field) {}
+
+ clang::MemberExpr* member;
+ bool as_eagerly_finalized;
+ FieldPoint* field;
+ };
+
+ typedef std::vector<Error> Errors;
+
+ CheckFinalizerVisitor(RecordCache* cache, bool is_eagerly_finalized);
+
+ Errors& finalized_fields();
+
+ bool WalkUpFromCXXOperatorCallExpr(clang::CXXOperatorCallExpr* expr);
+ bool WalkUpFromCallExpr(clang::CallExpr* expr);
+
+ bool VisitMemberExpr(clang::MemberExpr* member);
+
+ private:
+ bool MightBeCollected(FieldPoint* point, bool* as_eagerly_finalized);
+
+ bool blacklist_context_;
+ Errors finalized_fields_;
+ std::set<clang::MemberExpr*> seen_members_;
+ RecordCache* cache_;
+ bool is_eagerly_finalized_;
+};
+
+#endif // TOOLS_BLINK_GC_PLUGIN_CHECK_FINALIZER_VISITOR_H_
« no previous file with comments | « tools/clang/blink_gc_plugin/CheckFieldsVisitor.cpp ('k') | tools/clang/blink_gc_plugin/CheckFinalizerVisitor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698