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 <algorithm> | 10 #include <algorithm> |
(...skipping 23 matching lines...) Expand all Loading... |
34 ChromeClassTester::ChromeClassTester(CompilerInstance& instance, | 34 ChromeClassTester::ChromeClassTester(CompilerInstance& instance, |
35 const Options& options) | 35 const Options& options) |
36 : options_(options), | 36 : options_(options), |
37 instance_(instance), | 37 instance_(instance), |
38 diagnostic_(instance.getDiagnostics()) { | 38 diagnostic_(instance.getDiagnostics()) { |
39 BuildBannedLists(); | 39 BuildBannedLists(); |
40 } | 40 } |
41 | 41 |
42 ChromeClassTester::~ChromeClassTester() {} | 42 ChromeClassTester::~ChromeClassTester() {} |
43 | 43 |
44 void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) { | |
45 pending_class_decls_.push_back(tag); | |
46 } | |
47 | |
48 bool ChromeClassTester::HandleTopLevelDecl(DeclGroupRef group_ref) { | |
49 for (size_t i = 0; i < pending_class_decls_.size(); ++i) | |
50 CheckTag(pending_class_decls_[i]); | |
51 pending_class_decls_.clear(); | |
52 | |
53 return true; // true means continue parsing. | |
54 } | |
55 | |
56 void ChromeClassTester::CheckTag(TagDecl* tag) { | 44 void ChromeClassTester::CheckTag(TagDecl* tag) { |
57 // We handle class types here where we have semantic information. We can only | 45 // We handle class types here where we have semantic information. We can only |
58 // check structs/classes/enums here, but we get a bunch of nice semantic | 46 // check structs/classes/enums here, but we get a bunch of nice semantic |
59 // information instead of just parsing information. | 47 // information instead of just parsing information. |
60 | 48 |
61 if (CXXRecordDecl* record = dyn_cast<CXXRecordDecl>(tag)) { | 49 if (CXXRecordDecl* record = dyn_cast<CXXRecordDecl>(tag)) { |
62 if (InBannedNamespace(record)) | 50 if (InBannedNamespace(record)) |
63 return; | 51 return; |
64 | 52 |
65 SourceLocation record_location = record->getInnerLocStart(); | 53 SourceLocation record_location = record->getInnerLocStart(); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 320 } |
333 | 321 |
334 *filename = ploc.getFilename(); | 322 *filename = ploc.getFilename(); |
335 return true; | 323 return true; |
336 } | 324 } |
337 | 325 |
338 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { | 326 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { |
339 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error | 327 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error |
340 : DiagnosticsEngine::Warning; | 328 : DiagnosticsEngine::Warning; |
341 } | 329 } |
OLD | NEW |