Chromium Code Reviews| Index: tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp |
| diff --git a/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp b/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp |
| index d24d67ade4ff4c37aa2016b8d4d76567ea422652..f48b6e06e1d7d22c038601d8dbef0593b02294e5 100644 |
| --- a/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp |
| +++ b/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp |
| @@ -322,7 +322,9 @@ class CheckDispatchVisitor : public RecursiveASTVisitor<CheckDispatchVisitor> { |
| class CheckTraceVisitor : public RecursiveASTVisitor<CheckTraceVisitor> { |
| public: |
| CheckTraceVisitor(CXXMethodDecl* trace, RecordInfo* info) |
| - : trace_(trace), info_(info) {} |
| + : trace_(trace), info_(info), delegates_to_traceimpl_(false) {} |
| + |
| + bool delegates_to_traceimpl() const { return delegates_to_traceimpl_; } |
| bool VisitMemberExpr(MemberExpr* member) { |
| // In weak callbacks, consider any occurrence as a correct usage. |
| @@ -383,6 +385,11 @@ class CheckTraceVisitor : public RecursiveASTVisitor<CheckTraceVisitor> { |
| if (CXXMemberCallExpr* expr = dyn_cast<CXXMemberCallExpr>(call)) { |
| if (CheckTraceFieldCall(expr) || CheckRegisterWeakMembers(expr)) |
| return true; |
| + |
| + if (expr->getMethodDecl()->getNameAsString() == kTraceImplName) { |
| + delegates_to_traceimpl_ = true; |
| + return true; |
| + } |
| } |
| CheckTraceBaseCall(call); |
| @@ -415,6 +422,23 @@ class CheckTraceVisitor : public RecursiveASTVisitor<CheckTraceVisitor> { |
| void CheckCXXDependentScopeMemberExpr(CallExpr* call, |
| CXXDependentScopeMemberExpr* expr) { |
| string fn_name = expr->getMember().getAsString(); |
| + |
| + // Check for VisitorDispatcher::trace(field) |
| + if (!expr->isImplicitAccess()) { |
| + if (clang::DeclRefExpr* base_decl = |
| + clang::dyn_cast<clang::DeclRefExpr>(expr->getBase())) { |
| + if (Config::IsVisitorDispatcherType(base_decl->getType()) && |
| + call->getNumArgs() == 1 && fn_name == kTraceName) { |
| + FindFieldVisitor finder; |
| + finder.TraverseStmt(call->getArg(0)); |
| + if (finder.field()) |
| + FoundField(finder.field()); |
| + |
| + return; |
| + } |
| + } |
| + } |
| + |
| CXXRecordDecl* tmpl = GetDependentTemplatedDecl(expr); |
| if (!tmpl) |
| return; |
| @@ -565,6 +589,7 @@ class CheckTraceVisitor : public RecursiveASTVisitor<CheckTraceVisitor> { |
| CXXMethodDecl* trace_; |
| RecordInfo* info_; |
| + bool delegates_to_traceimpl_; |
| }; |
| // This visitor checks that the fields of a class and the fields of |
| @@ -1303,6 +1328,12 @@ class BlinkGCPluginConsumer : public ASTConsumer { |
| CheckTraceVisitor visitor(trace, parent); |
| visitor.TraverseCXXMethodDecl(trace); |
| + // Skip reporting if this trace method is a just delegate to |
| + // traceImplmethod. |
|
Yuta Kitamura
2014/12/24 06:31:18
nit: space between "traceImpl" and "method"
kouhei (in TOK)
2014/12/24 09:03:04
Done.
|
| + // We will report on CheckTraceMethod on traceImpl method. |
| + if (visitor.delegates_to_traceimpl()) |
| + return; |
| + |
| for (RecordInfo::Bases::iterator it = parent->GetBases().begin(); |
| it != parent->GetBases().end(); |
| ++it) { |