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 // A general interface for filtering and only acting on classes in Chromium C++ | 5 // A general interface for filtering and only acting on classes in Chromium C++ |
6 // code. | 6 // code. |
7 | 7 |
8 #include "ChromeClassTester.h" | 8 #include "ChromeClassTester.h" |
9 | 9 |
10 #include <sys/param.h> | 10 #include <sys/param.h> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 std::string base_name = record->getNameAsString(); | 84 std::string base_name = record->getNameAsString(); |
85 if (IsIgnoredType(base_name)) | 85 if (IsIgnoredType(base_name)) |
86 return; | 86 return; |
87 | 87 |
88 // We ignore all classes that end with "Matcher" because they're probably | 88 // We ignore all classes that end with "Matcher" because they're probably |
89 // GMock artifacts. | 89 // GMock artifacts. |
90 if (ends_with(base_name, "Matcher")) | 90 if (ends_with(base_name, "Matcher")) |
91 return; | 91 return; |
92 | 92 |
93 CheckChromeClass(record_location, record); | 93 CheckChromeClass(record_location, record); |
| 94 } else if (EnumDecl* enum_decl = dyn_cast<EnumDecl>(tag)) { |
| 95 SourceLocation enum_location = enum_decl->getInnerLocStart(); |
| 96 if (InBannedDirectory(enum_location)) |
| 97 return; |
| 98 |
| 99 std::string base_name = enum_decl->getNameAsString(); |
| 100 if (IsIgnoredType(base_name)) |
| 101 return; |
| 102 |
| 103 CheckChromeEnum(enum_location, enum_decl); |
94 } | 104 } |
95 } | 105 } |
96 | 106 |
97 void ChromeClassTester::emitWarning(SourceLocation loc, | 107 void ChromeClassTester::emitWarning(SourceLocation loc, |
98 const char* raw_error) { | 108 const char* raw_error) { |
99 FullSourceLoc full(loc, instance().getSourceManager()); | 109 FullSourceLoc full(loc, instance().getSourceManager()); |
100 std::string err; | 110 std::string err; |
101 err = "[chromium-style] "; | 111 err = "[chromium-style] "; |
102 err += raw_error; | 112 err += raw_error; |
103 DiagnosticIDs::Level level = | 113 DiagnosticIDs::Level level = |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 ignored_record_names_.insert("AutocompleteController"); | 198 ignored_record_names_.insert("AutocompleteController"); |
189 ignored_record_names_.insert("HistoryURLProvider"); | 199 ignored_record_names_.insert("HistoryURLProvider"); |
190 | 200 |
191 // Because of chrome frame | 201 // Because of chrome frame |
192 ignored_record_names_.insert("ReliabilityTestSuite"); | 202 ignored_record_names_.insert("ReliabilityTestSuite"); |
193 | 203 |
194 // Used over in the net unittests. A large enough bundle of integers with 1 | 204 // Used over in the net unittests. A large enough bundle of integers with 1 |
195 // non-pod class member. Probably harmless. | 205 // non-pod class member. Probably harmless. |
196 ignored_record_names_.insert("MockTransaction"); | 206 ignored_record_names_.insert("MockTransaction"); |
197 | 207 |
| 208 // Enum type with _LAST members where _LAST doesn't mean last enum value. |
| 209 ignored_record_names_.insert("ServerFieldType"); |
| 210 |
198 // Used heavily in ui_unittests and once in views_unittests. Fixing this | 211 // Used heavily in ui_unittests and once in views_unittests. Fixing this |
199 // isn't worth the overhead of an additional library. | 212 // isn't worth the overhead of an additional library. |
200 ignored_record_names_.insert("TestAnimationDelegate"); | 213 ignored_record_names_.insert("TestAnimationDelegate"); |
201 | 214 |
202 // Part of our public interface that nacl and friends use. (Arguably, this | 215 // Part of our public interface that nacl and friends use. (Arguably, this |
203 // should mean that this is a higher priority but fixing this looks hard.) | 216 // should mean that this is a higher priority but fixing this looks hard.) |
204 ignored_record_names_.insert("PluginVersionInfo"); | 217 ignored_record_names_.insert("PluginVersionInfo"); |
205 | 218 |
206 // Measured performance improvement on cc_perftests. See | 219 // Measured performance improvement on cc_perftests. See |
207 // https://codereview.chromium.org/11299290/ | 220 // https://codereview.chromium.org/11299290/ |
208 ignored_record_names_.insert("QuadF"); | 221 ignored_record_names_.insert("QuadF"); |
| 222 |
| 223 // Enum type with _LAST members where _LAST doesn't mean last enum value. |
| 224 ignored_record_names_.insert("ViewID"); |
209 } | 225 } |
210 | 226 |
211 std::string ChromeClassTester::GetNamespaceImpl(const DeclContext* context, | 227 std::string ChromeClassTester::GetNamespaceImpl(const DeclContext* context, |
212 const std::string& candidate) { | 228 const std::string& candidate) { |
213 switch (context->getDeclKind()) { | 229 switch (context->getDeclKind()) { |
214 case Decl::TranslationUnit: { | 230 case Decl::TranslationUnit: { |
215 return candidate; | 231 return candidate; |
216 } | 232 } |
217 case Decl::Namespace: { | 233 case Decl::Namespace: { |
218 const NamespaceDecl* decl = dyn_cast<NamespaceDecl>(context); | 234 const NamespaceDecl* decl = dyn_cast<NamespaceDecl>(context); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); | 308 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); |
293 if (ploc.isInvalid()) { | 309 if (ploc.isInvalid()) { |
294 // If we're in an invalid location, we're looking at things that aren't | 310 // If we're in an invalid location, we're looking at things that aren't |
295 // actually stated in the source. | 311 // actually stated in the source. |
296 return false; | 312 return false; |
297 } | 313 } |
298 | 314 |
299 *filename = ploc.getFilename(); | 315 *filename = ploc.getFilename(); |
300 return true; | 316 return true; |
301 } | 317 } |
OLD | NEW |