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