| 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 #include "CollectVisitor.h" | 5 #include "CollectVisitor.h" |
| 6 | 6 |
| 7 #include "Config.h" | 7 #include "Config.h" |
| 8 | 8 |
| 9 using namespace clang; | 9 using namespace clang; |
| 10 | 10 |
| 11 CollectVisitor::CollectVisitor() { | 11 CollectVisitor::CollectVisitor(bool check_var_decls) |
| 12 } | 12 : check_var_decls_(check_var_decls), var_visitor_(this) {} |
| 13 | 13 |
| 14 CollectVisitor::RecordVector& CollectVisitor::record_decls() { | 14 CollectVisitor::RecordVector& CollectVisitor::record_decls() { |
| 15 return record_decls_; | 15 return record_decls_; |
| 16 } | 16 } |
| 17 | 17 |
| 18 CollectVisitor::MethodVector& CollectVisitor::trace_decls() { | 18 CollectVisitor::MethodVector& CollectVisitor::trace_decls() { |
| 19 return trace_decls_; | 19 return trace_decls_; |
| 20 } | 20 } |
| 21 | 21 |
| 22 const CollectVisitor::SingletonVector& CollectVisitor::singleton_decls() const { |
| 23 return singleton_decls_; |
| 24 } |
| 25 |
| 22 bool CollectVisitor::VisitCXXRecordDecl(CXXRecordDecl* record) { | 26 bool CollectVisitor::VisitCXXRecordDecl(CXXRecordDecl* record) { |
| 23 if (record->hasDefinition() && record->isCompleteDefinition()) | 27 if (record->hasDefinition() && record->isCompleteDefinition()) |
| 24 record_decls_.push_back(record); | 28 record_decls_.push_back(record); |
| 25 return true; | 29 return true; |
| 26 } | 30 } |
| 27 | 31 |
| 28 bool CollectVisitor::VisitCXXMethodDecl(CXXMethodDecl* method) { | 32 bool CollectVisitor::VisitCXXMethodDecl(CXXMethodDecl* method) { |
| 29 if (method->isThisDeclarationADefinition() && Config::IsTraceMethod(method)) | 33 if (method->isThisDeclarationADefinition() && Config::IsTraceMethod(method)) |
| 30 trace_decls_.push_back(method); | 34 trace_decls_.push_back(method); |
| 31 return true; | 35 return true; |
| 32 } | 36 } |
| 37 |
| 38 bool CollectVisitor::LocalVarsVisitor::VisitVarDecl(VarDecl* decl) { |
| 39 if (Config::IsStaticSingleton(decl) && !Config::IsIgnoreAnnotated(decl) && |
| 40 decl->isStaticLocal()) |
| 41 parent_->singleton_decls_.push_back(decl); |
| 42 return true; |
| 43 } |
| 44 |
| 45 bool CollectVisitor::VisitFunctionDecl(FunctionDecl* decl) { |
| 46 if (!check_var_decls_) |
| 47 return true; |
| 48 |
| 49 if (!decl->isThisDeclarationADefinition()) |
| 50 return true; |
| 51 |
| 52 if (Stmt* body = decl->getBody()) |
| 53 var_visitor_.TraverseStmt(body); |
| 54 return true; |
| 55 } |
| OLD | NEW |