OLD | NEW |
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 // Registers notes to make it easier to interpret warnings. | 128 // Registers notes to make it easier to interpret warnings. |
129 diag_note_inheritance_ = | 129 diag_note_inheritance_ = |
130 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteInheritance); | 130 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteInheritance); |
131 diag_note_implicit_dtor_ = | 131 diag_note_implicit_dtor_ = |
132 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteImplicitDtor); | 132 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNoteImplicitDtor); |
133 diag_note_public_dtor_ = | 133 diag_note_public_dtor_ = |
134 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNotePublicDtor); | 134 diagnostic().getCustomDiagID(DiagnosticsEngine::Note, kNotePublicDtor); |
135 diag_note_protected_non_virtual_dtor_ = diagnostic().getCustomDiagID( | 135 diag_note_protected_non_virtual_dtor_ = diagnostic().getCustomDiagID( |
136 DiagnosticsEngine::Note, kNoteProtectedNonVirtualDtor); | 136 DiagnosticsEngine::Note, kNoteProtectedNonVirtualDtor); |
| 137 |
| 138 if (options.check_ipc) { |
| 139 ipc_checker_.reset(new CheckIPCVisitor(instance)); |
| 140 } |
137 } | 141 } |
138 | 142 |
139 bool FindBadConstructsConsumer::VisitDecl(clang::Decl* decl) { | 143 bool FindBadConstructsConsumer::VisitDecl(clang::Decl* decl) { |
140 clang::TagDecl* tag_decl = dyn_cast<clang::TagDecl>(decl); | 144 clang::TagDecl* tag_decl = dyn_cast<clang::TagDecl>(decl); |
141 if (tag_decl && tag_decl->isCompleteDefinition()) | 145 if (tag_decl && tag_decl->isCompleteDefinition()) |
142 CheckTag(tag_decl); | 146 CheckTag(tag_decl); |
143 return true; | 147 return true; |
144 } | 148 } |
145 | 149 |
146 void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location, | 150 void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 ++iter) { | 215 ++iter) { |
212 std::string name = iter->getNameAsString(); | 216 std::string name = iter->getNameAsString(); |
213 if (((name.size() > 4 && name.compare(name.size() - 4, 4, "Last") == 0) || | 217 if (((name.size() > 4 && name.compare(name.size() - 4, 4, "Last") == 0) || |
214 (name.size() > 5 && name.compare(name.size() - 5, 5, "_LAST") == 0)) && | 218 (name.size() > 5 && name.compare(name.size() - 5, 5, "_LAST") == 0)) && |
215 iter->getInitVal() < max_so_far) { | 219 iter->getInitVal() < max_so_far) { |
216 diagnostic().Report(iter->getLocation(), diag_bad_enum_last_value_); | 220 diagnostic().Report(iter->getLocation(), diag_bad_enum_last_value_); |
217 } | 221 } |
218 } | 222 } |
219 } | 223 } |
220 | 224 |
| 225 void FindBadConstructsConsumer::HandleTranslationUnit(ASTContext& context) { |
| 226 ChromeClassTester::HandleTranslationUnit(context); |
| 227 if (auto checker = ipc_checker()) { |
| 228 checker->Visit(context); |
| 229 } |
| 230 } |
| 231 |
221 void FindBadConstructsConsumer::CheckCtorDtorWeight( | 232 void FindBadConstructsConsumer::CheckCtorDtorWeight( |
222 SourceLocation record_location, | 233 SourceLocation record_location, |
223 CXXRecordDecl* record) { | 234 CXXRecordDecl* record) { |
224 // We don't handle anonymous structs. If this record doesn't have a | 235 // We don't handle anonymous structs. If this record doesn't have a |
225 // name, it's of the form: | 236 // name, it's of the form: |
226 // | 237 // |
227 // struct { | 238 // struct { |
228 // ... | 239 // ... |
229 // } name_; | 240 // } name_; |
230 if (record->getIdentifier() == NULL) | 241 if (record->getIdentifier() == NULL) |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 // one of those, it means there is at least one member after a factory. | 877 // one of those, it means there is at least one member after a factory. |
867 if (weak_ptr_factory_location.isValid() && | 878 if (weak_ptr_factory_location.isValid() && |
868 !param_is_weak_ptr_factory_to_self) { | 879 !param_is_weak_ptr_factory_to_self) { |
869 diagnostic().Report(weak_ptr_factory_location, | 880 diagnostic().Report(weak_ptr_factory_location, |
870 diag_weak_ptr_factory_order_); | 881 diag_weak_ptr_factory_order_); |
871 } | 882 } |
872 } | 883 } |
873 } | 884 } |
874 | 885 |
875 } // namespace chrome_checker | 886 } // namespace chrome_checker |
OLD | NEW |