| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_ | 5 #ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_ |
| 6 #define TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_ | 6 #define TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "RecordInfo.h" | 10 #include "RecordInfo.h" |
| 11 #include "clang/AST/AST.h" | 11 #include "clang/AST/AST.h" |
| 12 #include "clang/AST/RecursiveASTVisitor.h" | 12 #include "clang/AST/RecursiveASTVisitor.h" |
| 13 | 13 |
| 14 class RecordCache; | 14 class RecordCache; |
| 15 class RecordInfo; | 15 class RecordInfo; |
| 16 | 16 |
| 17 // This visitor checks a tracing method by traversing its body. | 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. | 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. | 19 // - A base is traced if a base-qualified call to a trace method is found. |
| 20 class CheckTraceVisitor : public clang::RecursiveASTVisitor<CheckTraceVisitor> { | 20 class CheckTraceVisitor : public clang::RecursiveASTVisitor<CheckTraceVisitor> { |
| 21 public: | 21 public: |
| 22 CheckTraceVisitor(clang::CXXMethodDecl* trace, | 22 CheckTraceVisitor(clang::CXXMethodDecl* trace, |
| 23 RecordInfo* info, | 23 RecordInfo* info, |
| 24 RecordCache* cache); | 24 RecordCache* cache); |
| 25 | 25 |
| 26 bool delegates_to_traceimpl() const; | |
| 27 | |
| 28 bool VisitMemberExpr(clang::MemberExpr* member); | 26 bool VisitMemberExpr(clang::MemberExpr* member); |
| 29 bool VisitCallExpr(clang::CallExpr* call); | 27 bool VisitCallExpr(clang::CallExpr* call); |
| 30 | 28 |
| 31 private: | 29 private: |
| 32 bool IsTraceCallName(const std::string& name); | 30 bool IsTraceCallName(const std::string& name); |
| 33 | 31 |
| 34 clang::CXXRecordDecl* GetDependentTemplatedDecl( | 32 clang::CXXRecordDecl* GetDependentTemplatedDecl( |
| 35 clang::CXXDependentScopeMemberExpr* expr); | 33 clang::CXXDependentScopeMemberExpr* expr); |
| 36 | 34 |
| 37 void CheckCXXDependentScopeMemberExpr( | 35 void CheckCXXDependentScopeMemberExpr( |
| 38 clang::CallExpr* call, | 36 clang::CallExpr* call, |
| 39 clang::CXXDependentScopeMemberExpr* expr); | 37 clang::CXXDependentScopeMemberExpr* expr); |
| 40 bool CheckTraceBaseCall(clang::CallExpr* call); | 38 bool CheckTraceBaseCall(clang::CallExpr* call); |
| 41 bool CheckTraceFieldMemberCall(clang::CXXMemberCallExpr* call); | 39 bool CheckTraceFieldMemberCall(clang::CXXMemberCallExpr* call); |
| 42 bool CheckTraceFieldCall(const std::string& name, | 40 bool CheckTraceFieldCall(const std::string& name, |
| 43 clang::CXXRecordDecl* callee, | 41 clang::CXXRecordDecl* callee, |
| 44 clang::Expr* arg); | 42 clang::Expr* arg); |
| 45 bool CheckRegisterWeakMembers(clang::CXXMemberCallExpr* call); | 43 bool CheckRegisterWeakMembers(clang::CXXMemberCallExpr* call); |
| 46 | 44 |
| 47 bool IsWeakCallback() const; | 45 bool IsWeakCallback() const; |
| 48 | 46 |
| 49 void MarkTraced(RecordInfo::Fields::iterator it); | 47 void MarkTraced(RecordInfo::Fields::iterator it); |
| 50 void FoundField(clang::FieldDecl* field); | 48 void FoundField(clang::FieldDecl* field); |
| 51 void MarkAllWeakMembersTraced(); | 49 void MarkAllWeakMembersTraced(); |
| 52 | 50 |
| 53 clang::CXXMethodDecl* trace_; | 51 clang::CXXMethodDecl* trace_; |
| 54 RecordInfo* info_; | 52 RecordInfo* info_; |
| 55 RecordCache* cache_; | 53 RecordCache* cache_; |
| 56 bool delegates_to_traceimpl_; | |
| 57 }; | 54 }; |
| 58 | 55 |
| 59 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_ | 56 #endif // TOOLS_BLINK_GC_PLUGIN_CHECK_TRACE_VISITOR_H_ |
| OLD | NEW |