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

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

Issue 597863002: Update plugin to handle new style rules for virtual annotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add copyright blurb Created 6 years, 2 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
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 // 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 18 matching lines...) Expand all
29 29
30 namespace chrome_checker { 30 namespace chrome_checker {
31 31
32 // Searches for constructs that we know we don't want in the Chromium code base. 32 // Searches for constructs that we know we don't want in the Chromium code base.
33 class FindBadConstructsConsumer : public ChromeClassTester { 33 class FindBadConstructsConsumer : public ChromeClassTester {
34 public: 34 public:
35 FindBadConstructsConsumer(clang::CompilerInstance& instance, 35 FindBadConstructsConsumer(clang::CompilerInstance& instance,
36 const Options& options); 36 const Options& options);
37 37
38 // ChromeClassTester overrides: 38 // ChromeClassTester overrides:
39 virtual void CheckChromeClass(clang::SourceLocation record_location, 39 void CheckChromeClass(clang::SourceLocation record_location,
40 clang::CXXRecordDecl* record); 40 clang::CXXRecordDecl* record) override;
41 virtual void CheckChromeEnum(clang::SourceLocation enum_location, 41 void CheckChromeEnum(clang::SourceLocation enum_location,
42 clang::EnumDecl* enum_decl); 42 clang::EnumDecl* enum_decl) override;
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 CheckVirtualSpecifiers(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_specifier_;
87 unsigned diag_base_method_virtual_and_final_;
89 unsigned diag_no_explicit_dtor_; 88 unsigned diag_no_explicit_dtor_;
90 unsigned diag_public_dtor_; 89 unsigned diag_public_dtor_;
91 unsigned diag_protected_non_virtual_dtor_; 90 unsigned diag_protected_non_virtual_dtor_;
92 unsigned diag_weak_ptr_factory_order_; 91 unsigned diag_weak_ptr_factory_order_;
93 unsigned diag_bad_enum_last_value_; 92 unsigned diag_bad_enum_last_value_;
94 unsigned diag_note_inheritance_; 93 unsigned diag_note_inheritance_;
95 unsigned diag_note_implicit_dtor_; 94 unsigned diag_note_implicit_dtor_;
96 unsigned diag_note_public_dtor_; 95 unsigned diag_note_public_dtor_;
97 unsigned diag_note_protected_non_virtual_dtor_; 96 unsigned diag_note_protected_non_virtual_dtor_;
98 }; 97 };
99 98
100 } // namespace chrome_checker 99 } // namespace chrome_checker
OLDNEW
« no previous file with comments | « tools/clang/plugins/FindBadConstructsAction.cpp ('k') | tools/clang/plugins/FindBadConstructsConsumer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698