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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 // 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 return true; // true means continue parsing. 56 return true; // true means continue parsing.
57 } 57 }
58 58
59 void ChromeClassTester::CheckTag(TagDecl* tag) { 59 void ChromeClassTester::CheckTag(TagDecl* tag) {
60 // 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
61 // 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
62 // information instead of just parsing information. 62 // information instead of just parsing information.
63 63
64 if (CXXRecordDecl* record = dyn_cast<CXXRecordDecl>(tag)) { 64 if (CXXRecordDecl* record = dyn_cast<CXXRecordDecl>(tag)) {
65 // If this is a POD or a class template or a type dependent on a
66 // templated class, assume there's no ctor/dtor/virtual method
67 // optimization that we can do.
68 if (record->isPOD() ||
69 record->getDescribedClassTemplate() ||
70 record->getTemplateSpecializationKind() ||
71 record->isDependentType())
72 return;
73
74 if (InBannedNamespace(record)) 65 if (InBannedNamespace(record))
75 return; 66 return;
76 67
77 SourceLocation record_location = record->getInnerLocStart(); 68 SourceLocation record_location = record->getInnerLocStart();
78 if (InBannedDirectory(record_location)) 69 if (InBannedDirectory(record_location))
79 return; 70 return;
80 71
81 // We sadly need to maintain a blacklist of types that violate these 72 // We sadly need to maintain a blacklist of types that violate these
82 // rules, but do so for good reason or due to limitations of this 73 // rules, but do so for good reason or due to limitations of this
83 // checker (i.e., we don't handle extern templates very well). 74 // checker (i.e., we don't handle extern templates very well).
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); 293 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location);
303 if (ploc.isInvalid()) { 294 if (ploc.isInvalid()) {
304 // If we're in an invalid location, we're looking at things that aren't 295 // If we're in an invalid location, we're looking at things that aren't
305 // actually stated in the source. 296 // actually stated in the source.
306 return false; 297 return false;
307 } 298 }
308 299
309 *filename = ploc.getFilename(); 300 *filename = ploc.getFilename();
310 return true; 301 return true;
311 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698