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

Side by Side Diff: tools/clang/plugins/ChromeClassTester.cpp

Issue 10808078: Clang plugin: defer checking of tag decls until after top-level decl fully parsed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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 // 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 25 matching lines...) Expand all
36 36
37 ChromeClassTester::ChromeClassTester(CompilerInstance& instance) 37 ChromeClassTester::ChromeClassTester(CompilerInstance& instance)
38 : instance_(instance), 38 : instance_(instance),
39 diagnostic_(instance.getDiagnostics()) { 39 diagnostic_(instance.getDiagnostics()) {
40 BuildBannedLists(); 40 BuildBannedLists();
41 } 41 }
42 42
43 ChromeClassTester::~ChromeClassTester() {} 43 ChromeClassTester::~ChromeClassTester() {}
44 44
45 void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) { 45 void ChromeClassTester::HandleTagDeclDefinition(TagDecl* tag) {
46 // Defer processing of this tag until its containing top-level
47 // declaration has been fully parsed. See crbug.com/136863.
48 pending_class_decls_.push_back(tag);
49 }
50
51 bool ChromeClassTester::HandleTopLevelDecl(DeclGroupRef D) {
52 for (size_t i = 0; i < pending_class_decls_.size(); ++i)
53 CheckTag(pending_class_decls_[i]);
54 pending_class_decls_.clear();
55
56 return true; // true means continue parsing.
57 }
58
59 void ChromeClassTester::CheckTag(TagDecl* tag) {
46 // We handle class types here where we have semantic information. We can only 60 // We handle class types here where we have semantic information. We can only
47 // check structs/classes/enums here, but we get a bunch of nice semantic 61 // check structs/classes/enums here, but we get a bunch of nice semantic
48 // information instead of just parsing information. 62 // information instead of just parsing information.
49 63
50 if (CXXRecordDecl* record = dyn_cast<CXXRecordDecl>(tag)) { 64 if (CXXRecordDecl* record = dyn_cast<CXXRecordDecl>(tag)) {
51 // If this is a POD or a class template or a type dependent on a 65 // If this is a POD or a class template or a type dependent on a
52 // templated class, assume there's no ctor/dtor/virtual method 66 // templated class, assume there's no ctor/dtor/virtual method
53 // optimization that we can do. 67 // optimization that we can do.
54 if (record->isPOD() || 68 if (record->isPOD() ||
55 record->getDescribedClassTemplate() || 69 record->getDescribedClassTemplate() ||
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); 285 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location);
272 if (ploc.isInvalid()) { 286 if (ploc.isInvalid()) {
273 // If we're in an invalid location, we're looking at things that aren't 287 // If we're in an invalid location, we're looking at things that aren't
274 // actually stated in the source. 288 // actually stated in the source.
275 return false; 289 return false;
276 } 290 }
277 291
278 *filename = ploc.getFilename(); 292 *filename = ploc.getFilename();
279 return true; 293 return true;
280 } 294 }
OLDNEW
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.h ('k') | tools/clang/plugins/tests/nested_class_inline_ctor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698