Chromium Code Reviews| Index: tools/clang/plugins/FindBadConstructsConsumer.cpp |
| diff --git a/tools/clang/plugins/FindBadConstructsConsumer.cpp b/tools/clang/plugins/FindBadConstructsConsumer.cpp |
| index d1fc29df7ce5117d8a58fcf762917d730d7eddc0..59b1c0a8c50d3a18df4cad3419f67178af98374d 100644 |
| --- a/tools/clang/plugins/FindBadConstructsConsumer.cpp |
| +++ b/tools/clang/plugins/FindBadConstructsConsumer.cpp |
| @@ -103,6 +103,10 @@ bool IsPodOrTemplateType(const CXXRecordDecl& record) { |
| FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance, |
| const Options& options) |
| : ChromeClassTester(instance, options) { |
| + if (options.check_ipc) { |
| + ipc_visitor_.reset(new CheckIPCVisitor(instance)); |
| + } |
| + |
| // Messages for virtual method specifiers. |
| diag_method_requires_override_ = |
| diagnostic().getCustomDiagID(getErrorLevel(), kMethodRequiresOverride); |
| @@ -136,6 +140,24 @@ FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance, |
| DiagnosticsEngine::Note, kNoteProtectedNonVirtualDtor); |
| } |
| +void FindBadConstructsConsumer::Visit(ASTContext& context) { |
| + if (ipc_visitor_) ipc_visitor_->set_context(&context); |
| + RecursiveASTVisitor::TraverseDecl(context.getTranslationUnitDecl()); |
| + if (ipc_visitor_) ipc_visitor_->set_context(nullptr); |
| +} |
| + |
| +bool FindBadConstructsConsumer::shouldVisitTemplateInstantiations() const { |
| + return RecursiveASTVisitor::shouldVisitTemplateInstantiations() || |
|
dcheng
2016/03/07 23:44:39
I don't think we need to call the 'base' method he
Dmitry Skiba
2016/03/08 01:16:11
Yes, but it provides the value I "blend" with. I d
|
| + (ipc_visitor_ && ipc_visitor_->should_visit_template_instantiations()); |
| +} |
| + |
| +bool FindBadConstructsConsumer::TraverseDecl(Decl* decl) { |
| + if (ipc_visitor_) ipc_visitor_->BeginDecl(decl); |
| + bool result = RecursiveASTVisitor::TraverseDecl(decl); |
| + if (ipc_visitor_) ipc_visitor_->EndDecl(); |
| + return result; |
|
dcheng
2016/03/07 23:44:39
Seems like this should all just be in VisitDecl()
Dmitry Skiba
2016/03/08 01:16:11
VisitDecl() is called on leafs, so I won't be able
|
| +} |
| + |
| bool FindBadConstructsConsumer::VisitDecl(clang::Decl* decl) { |
| clang::TagDecl* tag_decl = dyn_cast<clang::TagDecl>(decl); |
| if (tag_decl && tag_decl->isCompleteDefinition()) |
| @@ -143,6 +165,17 @@ bool FindBadConstructsConsumer::VisitDecl(clang::Decl* decl) { |
| return true; |
| } |
| +bool FindBadConstructsConsumer::VisitTemplateSpecializationType( |
| + TemplateSpecializationType* spec) { |
| + if (ipc_visitor_) ipc_visitor_->VisitTemplateSpecializationType(spec); |
| + return true; |
| +} |
| + |
| +bool FindBadConstructsConsumer::VisitCallExpr(CallExpr* call_expr) { |
| + if (ipc_visitor_) ipc_visitor_->VisitCallExpr(call_expr); |
| + return true; |
| +} |
| + |
| void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location, |
| CXXRecordDecl* record) { |
| // By default, the clang checker doesn't check some types (templates, etc). |