1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_
6 #define TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_
10 #include "RecordInfo.h"
11 #include "clang/AST/AST.h"
12 #include "clang/AST/RecursiveASTVisitor.h"
17 // This visitor checks a tracing method by traversing its body.
18 // - A member field is considered traced if it is referenced in the body.
19 // - A base is traced if a base-qualified call to a trace method is found.
20 class CheckTraceVisitor
: public clang::RecursiveASTVisitor
<CheckTraceVisitor
> {
22 CheckTraceVisitor(clang::CXXMethodDecl
* trace
,
26 bool delegates_to_traceimpl() const;
28 bool VisitMemberExpr(clang::MemberExpr
* member
);
29 bool VisitCallExpr(clang::CallExpr
* call
);
32 bool IsTraceCallName(const std::string
& name
);
34 clang::CXXRecordDecl
* GetDependentTemplatedDecl(
35 clang::CXXDependentScopeMemberExpr
* expr
);
37 void CheckCXXDependentScopeMemberExpr(
38 clang::CallExpr
* call
,
39 clang::CXXDependentScopeMemberExpr
* expr
);
40 bool CheckTraceBaseCall(clang::CallExpr
* call
);
41 bool CheckTraceFieldMemberCall(clang::CXXMemberCallExpr
* call
);
42 bool CheckTraceFieldCall(const std::string
& name
,
43 clang::CXXRecordDecl
* callee
,
45 bool CheckRegisterWeakMembers(clang::CXXMemberCallExpr
* call
);
47 bool IsWeakCallback() const;
49 void MarkTraced(RecordInfo::Fields::iterator it
);
50 void FoundField(clang::FieldDecl
* field
);
51 void MarkAllWeakMembersTraced();
53 clang::CXXMethodDecl
* trace_
;
56 bool delegates_to_traceimpl_
;
59 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_