Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tools/clang/plugins/FindBadConstructsConsumer.cpp

Issue 1783803002: Revert of Clang plugin to check that unstable types are not used in IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/clang/plugins/FindBadConstructsConsumer.h ('k') | tools/clang/plugins/Options.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "FindBadConstructsConsumer.h" 5 #include "FindBadConstructsConsumer.h"
6 6
7 #include "clang/Frontend/CompilerInstance.h" 7 #include "clang/Frontend/CompilerInstance.h"
8 #include "clang/AST/Attr.h" 8 #include "clang/AST/Attr.h"
9 #include "clang/Lex/Lexer.h" 9 #include "clang/Lex/Lexer.h"
10 #include "llvm/Support/raw_ostream.h" 10 #include "llvm/Support/raw_ostream.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 record.getDescribedClassTemplate() || 96 record.getDescribedClassTemplate() ||
97 record.getTemplateSpecializationKind() || 97 record.getTemplateSpecializationKind() ||
98 record.isDependentType(); 98 record.isDependentType();
99 } 99 }
100 100
101 } // namespace 101 } // namespace
102 102
103 FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance, 103 FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance,
104 const Options& options) 104 const Options& options)
105 : ChromeClassTester(instance, options) { 105 : ChromeClassTester(instance, options) {
106 if (options.check_ipc) {
107 ipc_visitor_.reset(new CheckIPCVisitor(instance));
108 }
109
110 // Messages for virtual method specifiers. 106 // Messages for virtual method specifiers.
111 diag_method_requires_override_ = 107 diag_method_requires_override_ =
112 diagnostic().getCustomDiagID(getErrorLevel(), kMethodRequiresOverride); 108 diagnostic().getCustomDiagID(getErrorLevel(), kMethodRequiresOverride);
113 diag_redundant_virtual_specifier_ = 109 diag_redundant_virtual_specifier_ =
114 diagnostic().getCustomDiagID(getErrorLevel(), kRedundantVirtualSpecifier); 110 diagnostic().getCustomDiagID(getErrorLevel(), kRedundantVirtualSpecifier);
115 diag_base_method_virtual_and_final_ = 111 diag_base_method_virtual_and_final_ =
116 diagnostic().getCustomDiagID(getErrorLevel(), kBaseMethodVirtualAndFinal); 112 diagnostic().getCustomDiagID(getErrorLevel(), kBaseMethodVirtualAndFinal);
117 113
118 // Messages for destructors. 114 // Messages for destructors.
119 diag_no_explicit_dtor_ = 115 diag_no_explicit_dtor_ =
(...skipping 13 matching lines...) Expand all
133 diag_note_inheritance_ = 129 diag_note_inheritance_ =
134 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteInheritance); 130 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteInheritance);
135 diag_note_implicit_dtor_ = 131 diag_note_implicit_dtor_ =
136 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteImplicitDtor); 132 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteImplicitDtor);
137 diag_note_public_dtor_ = 133 diag_note_public_dtor_ =
138 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNotePublicDtor); 134 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNotePublicDtor);
139 diag_note_protected_non_virtual_dtor_ = diagnostic().getCustomDiagID( 135 diag_note_protected_non_virtual_dtor_ = diagnostic().getCustomDiagID(
140 DiagnosticsEngine::Note, kNoteProtectedNonVirtualDtor); 136 DiagnosticsEngine::Note, kNoteProtectedNonVirtualDtor);
141 } 137 }
142 138
143 void FindBadConstructsConsumer::Traverse(ASTContext& context) {
144 if (ipc_visitor_) ipc_visitor_->set_context(&context);
145 RecursiveASTVisitor::TraverseDecl(context.getTranslationUnitDecl());
146 if (ipc_visitor_) ipc_visitor_->set_context(nullptr);
147 }
148
149 bool FindBadConstructsConsumer::shouldVisitTemplateInstantiations() const {
150 return RecursiveASTVisitor::shouldVisitTemplateInstantiations() ||
151 (ipc_visitor_ && ipc_visitor_->should_visit_template_instantiations());
152 }
153
154 bool FindBadConstructsConsumer::TraverseDecl(Decl* decl) {
155 if (ipc_visitor_) ipc_visitor_->BeginDecl(decl);
156 bool result = RecursiveASTVisitor::TraverseDecl(decl);
157 if (ipc_visitor_) ipc_visitor_->EndDecl();
158 return result;
159 }
160
161 bool FindBadConstructsConsumer::VisitDecl(clang::Decl* decl) { 139 bool FindBadConstructsConsumer::VisitDecl(clang::Decl* decl) {
162 clang::TagDecl* tag_decl = dyn_cast<clang::TagDecl>(decl); 140 clang::TagDecl* tag_decl = dyn_cast<clang::TagDecl>(decl);
163 if (tag_decl && tag_decl->isCompleteDefinition()) 141 if (tag_decl && tag_decl->isCompleteDefinition())
164 CheckTag(tag_decl); 142 CheckTag(tag_decl);
165 return true; 143 return true;
166 } 144 }
167 145
168 bool FindBadConstructsConsumer::VisitTemplateSpecializationType(
169 TemplateSpecializationType* spec) {
170 if (ipc_visitor_) ipc_visitor_->VisitTemplateSpecializationType(spec);
171 return true;
172 }
173
174 bool FindBadConstructsConsumer::VisitCallExpr(CallExpr* call_expr) {
175 if (ipc_visitor_) ipc_visitor_->VisitCallExpr(call_expr);
176 return true;
177 }
178
179 void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location, 146 void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location,
180 CXXRecordDecl* record) { 147 CXXRecordDecl* record) {
181 // By default, the clang checker doesn't check some types (templates, etc). 148 // By default, the clang checker doesn't check some types (templates, etc).
182 // That was only a mistake; once Chromium code passes these checks, we should 149 // That was only a mistake; once Chromium code passes these checks, we should
183 // remove the "check-templates" option and remove this code. 150 // remove the "check-templates" option and remove this code.
184 // See crbug.com/441916 151 // See crbug.com/441916
185 if (!options_.check_templates && IsPodOrTemplateType(*record)) 152 if (!options_.check_templates && IsPodOrTemplateType(*record))
186 return; 153 return;
187 154
188 bool implementation_file = InImplementationFile(record_location); 155 bool implementation_file = InImplementationFile(record_location);
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 // one of those, it means there is at least one member after a factory. 870 // one of those, it means there is at least one member after a factory.
904 if (weak_ptr_factory_location.isValid() && 871 if (weak_ptr_factory_location.isValid() &&
905 !param_is_weak_ptr_factory_to_self) { 872 !param_is_weak_ptr_factory_to_self) {
906 diagnostic().Report(weak_ptr_factory_location, 873 diagnostic().Report(weak_ptr_factory_location,
907 diag_weak_ptr_factory_order_); 874 diag_weak_ptr_factory_order_);
908 } 875 }
909 } 876 }
910 } 877 }
911 878
912 } // namespace chrome_checker 879 } // namespace chrome_checker
OLDNEW
« no previous file with comments | « tools/clang/plugins/FindBadConstructsConsumer.h ('k') | tools/clang/plugins/Options.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698