Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / tools / clang / blink_gc_plugin / CheckTraceVisitor.h
blob580a6fba99bb1a2ad931df579763d05ba0e273ab
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_
8 #include <string>
10 #include "RecordInfo.h"
11 #include "clang/AST/AST.h"
12 #include "clang/AST/RecursiveASTVisitor.h"
14 class RecordCache;
15 class RecordInfo;
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> {
21 public:
22 CheckTraceVisitor(clang::CXXMethodDecl* trace,
23 RecordInfo* info,
24 RecordCache* cache);
26 bool delegates_to_traceimpl() const;
28 bool VisitMemberExpr(clang::MemberExpr* member);
29 bool VisitCallExpr(clang::CallExpr* call);
31 private:
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,
44 clang::Expr* arg);
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_;
54 RecordInfo* info_;
55 RecordCache* cache_;
56 bool delegates_to_traceimpl_;
59 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_