| 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 // This file defines a bunch of recurring problems in the Chromium C++ code. | 5 // This file defines a bunch of recurring problems in the Chromium C++ code. |
| 6 // | 6 // |
| 7 // Checks that are implemented: | 7 // Checks that are implemented: |
| 8 // - Constructors/Destructors should not be inlined if they are of a complex | 8 // - Constructors/Destructors should not be inlined if they are of a complex |
| 9 // class type. | 9 // class type. |
| 10 // - Missing "virtual" keywords on methods that should be virtual. | 10 // - Missing "virtual" keywords on methods that should be virtual. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 virtual void CheckChromeEnum(clang::SourceLocation enum_location, | 41 virtual void CheckChromeEnum(clang::SourceLocation enum_location, |
| 42 clang::EnumDecl* enum_decl); | 42 clang::EnumDecl* enum_decl); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // The type of problematic ref-counting pattern that was encountered. | 45 // The type of problematic ref-counting pattern that was encountered. |
| 46 enum RefcountIssue { None, ImplicitDestructor, PublicDestructor }; | 46 enum RefcountIssue { None, ImplicitDestructor, PublicDestructor }; |
| 47 | 47 |
| 48 void CheckCtorDtorWeight(clang::SourceLocation record_location, | 48 void CheckCtorDtorWeight(clang::SourceLocation record_location, |
| 49 clang::CXXRecordDecl* record); | 49 clang::CXXRecordDecl* record); |
| 50 | 50 |
| 51 void CheckVirtualMethod(const clang::CXXMethodDecl* method, | |
| 52 bool warn_on_inline_bodies); | |
| 53 | |
| 54 bool InTestingNamespace(const clang::Decl* record); | 51 bool InTestingNamespace(const clang::Decl* record); |
| 55 bool IsMethodInBannedOrTestingNamespace(const clang::CXXMethodDecl* method); | 52 bool IsMethodInBannedOrTestingNamespace(const clang::CXXMethodDecl* method); |
| 56 | 53 |
| 57 void CheckOverriddenMethod(const clang::CXXMethodDecl* method); | |
| 58 void CheckVirtualMethods(clang::SourceLocation record_location, | 54 void CheckVirtualMethods(clang::SourceLocation record_location, |
| 59 clang::CXXRecordDecl* record, | 55 clang::CXXRecordDecl* record, |
| 60 bool warn_on_inline_bodies); | 56 bool warn_on_inline_bodies); |
| 57 void CheckVirtualAnnotations(const clang::CXXMethodDecl* method); |
| 58 void CheckVirtualBodies(const clang::CXXMethodDecl* method); |
| 61 | 59 |
| 62 void CountType(const clang::Type* type, | 60 void CountType(const clang::Type* type, |
| 63 int* trivial_member, | 61 int* trivial_member, |
| 64 int* non_trivial_member, | 62 int* non_trivial_member, |
| 65 int* templated_non_trivial_member); | 63 int* templated_non_trivial_member); |
| 66 | 64 |
| 67 static RefcountIssue CheckRecordForRefcountIssue( | 65 static RefcountIssue CheckRecordForRefcountIssue( |
| 68 const clang::CXXRecordDecl* record, | 66 const clang::CXXRecordDecl* record, |
| 69 clang::SourceLocation& loc); | 67 clang::SourceLocation& loc); |
| 70 clang::DiagnosticsEngine::Level getErrorLevel(); | 68 clang::DiagnosticsEngine::Level getErrorLevel(); |
| 71 static bool IsRefCountedCallback(const clang::CXXBaseSpecifier* base, | 69 static bool IsRefCountedCallback(const clang::CXXBaseSpecifier* base, |
| 72 clang::CXXBasePath& path, | 70 clang::CXXBasePath& path, |
| 73 void* user_data); | 71 void* user_data); |
| 74 static bool HasPublicDtorCallback(const clang::CXXBaseSpecifier* base, | 72 static bool HasPublicDtorCallback(const clang::CXXBaseSpecifier* base, |
| 75 clang::CXXBasePath& path, | 73 clang::CXXBasePath& path, |
| 76 void* user_data); | 74 void* user_data); |
| 77 void PrintInheritanceChain(const clang::CXXBasePath& path); | 75 void PrintInheritanceChain(const clang::CXXBasePath& path); |
| 78 unsigned DiagnosticForIssue(RefcountIssue issue); | 76 unsigned DiagnosticForIssue(RefcountIssue issue); |
| 79 void CheckRefCountedDtors(clang::SourceLocation record_location, | 77 void CheckRefCountedDtors(clang::SourceLocation record_location, |
| 80 clang::CXXRecordDecl* record); | 78 clang::CXXRecordDecl* record); |
| 81 | 79 |
| 82 void CheckWeakPtrFactoryMembers(clang::SourceLocation record_location, | 80 void CheckWeakPtrFactoryMembers(clang::SourceLocation record_location, |
| 83 clang::CXXRecordDecl* record); | 81 clang::CXXRecordDecl* record); |
| 84 | 82 |
| 85 const Options options_; | 83 const Options options_; |
| 86 | 84 |
| 87 unsigned diag_method_requires_override_; | 85 unsigned diag_method_requires_override_; |
| 88 unsigned diag_method_requires_virtual_; | 86 unsigned diag_redundant_virtual_annotation_; |
| 87 unsigned diag_dtor_implicit_virtual_; |
| 88 unsigned diag_virtual_dtor_annotation_; |
| 89 unsigned diag_base_method_virtual_and_final_; |
| 89 unsigned diag_no_explicit_dtor_; | 90 unsigned diag_no_explicit_dtor_; |
| 90 unsigned diag_public_dtor_; | 91 unsigned diag_public_dtor_; |
| 91 unsigned diag_protected_non_virtual_dtor_; | 92 unsigned diag_protected_non_virtual_dtor_; |
| 92 unsigned diag_weak_ptr_factory_order_; | 93 unsigned diag_weak_ptr_factory_order_; |
| 93 unsigned diag_bad_enum_last_value_; | 94 unsigned diag_bad_enum_last_value_; |
| 94 unsigned diag_note_inheritance_; | 95 unsigned diag_note_inheritance_; |
| 95 unsigned diag_note_implicit_dtor_; | 96 unsigned diag_note_implicit_dtor_; |
| 96 unsigned diag_note_public_dtor_; | 97 unsigned diag_note_public_dtor_; |
| 97 unsigned diag_note_protected_non_virtual_dtor_; | 98 unsigned diag_note_protected_non_virtual_dtor_; |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 } // namespace chrome_checker | 101 } // namespace chrome_checker |
| OLD | NEW |