forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BlinkGCPlugin: Move CheckDispatchVisitor out of BlinkGCPlugin.cpp.
Part 6 of dividing a 2000-line cpp file. Nothing to note here; this patch is a simple code move. BUG=531879 R=haraken@chromium.org, oilpan-reviews@chromium.org, sigbjornf@opera.com Review URL: https://codereview.chromium.org/1377773002 Cr-Commit-Position: refs/heads/master@{#351293}
- Loading branch information
Showing
4 changed files
with
74 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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_DISPATCH_VISITOR_H_ | ||
#define TOOLS_BLINK_GC_PLUGIN_CHECK_DISPATCH_VISITOR_H_ | ||
|
||
#include "clang/AST/RecursiveASTVisitor.h" | ||
|
||
class RecordInfo; | ||
|
||
// This visitor checks that a method contains within its body, a call to a | ||
// method on the provided receiver class. This is used to check manual | ||
// dispatching for trace and finalize methods. | ||
class CheckDispatchVisitor | ||
: public clang::RecursiveASTVisitor<CheckDispatchVisitor> { | ||
public: | ||
explicit CheckDispatchVisitor(RecordInfo* receiver); | ||
|
||
bool dispatched_to_receiver(); | ||
|
||
bool VisitMemberExpr(clang::MemberExpr* member); | ||
bool VisitUnresolvedMemberExpr(clang::UnresolvedMemberExpr* member); | ||
|
||
private: | ||
RecordInfo* receiver_; | ||
bool dispatched_to_receiver_; | ||
}; | ||
|
||
#endif // TOOLS_BLINK_GC_PLUGIN_CHECK_DISPATCH_VISITOR_H_ |