Index: tools/clang/blink_gc_plugin/CheckDispatchVisitor.cpp |
diff --git a/tools/clang/blink_gc_plugin/CheckDispatchVisitor.cpp b/tools/clang/blink_gc_plugin/CheckDispatchVisitor.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9c3de6d86c30bc7212bb5b74d6f7dfb422c18344 |
--- /dev/null |
+++ b/tools/clang/blink_gc_plugin/CheckDispatchVisitor.cpp |
@@ -0,0 +1,42 @@ |
+// 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. |
+ |
+#include "CheckDispatchVisitor.h" |
+ |
+#include "Config.h" |
+#include "RecordInfo.h" |
+ |
+using namespace clang; |
+ |
+CheckDispatchVisitor::CheckDispatchVisitor(RecordInfo* receiver) |
+ : receiver_(receiver), |
+ dispatched_to_receiver_(false) { |
+} |
+ |
+bool CheckDispatchVisitor::dispatched_to_receiver() { |
+ return dispatched_to_receiver_; |
+} |
+ |
+bool CheckDispatchVisitor::VisitMemberExpr(MemberExpr* member) { |
+ if (CXXMethodDecl* fn = dyn_cast<CXXMethodDecl>(member->getMemberDecl())) { |
+ if (fn->getParent() == receiver_->record()) |
+ dispatched_to_receiver_ = true; |
+ } |
+ return true; |
+} |
+ |
+bool CheckDispatchVisitor::VisitUnresolvedMemberExpr( |
+ UnresolvedMemberExpr* member) { |
+ for (Decl* decl : member->decls()) { |
+ if (CXXMethodDecl* method = dyn_cast<CXXMethodDecl>(decl)) { |
+ if (method->getParent() == receiver_->record() && |
+ Config::GetTraceMethodType(method) == |
+ Config::TRACE_AFTER_DISPATCH_METHOD) { |
+ dispatched_to_receiver_ = true; |
+ return true; |
+ } |
+ } |
+ } |
+ return true; |
+} |