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

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

Issue 1703713002: clang-plugin: Enable RecursiveASTVisitor approach by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 #include "FindBadConstructsConsumer.h" 5 #include "FindBadConstructsConsumer.h"
6 6
7 #include "clang/Frontend/CompilerInstance.h" 7 #include "clang/Frontend/CompilerInstance.h"
8 #include "clang/AST/Attr.h" 8 #include "clang/AST/Attr.h"
9 #include "clang/Lex/Lexer.h" 9 #include "clang/Lex/Lexer.h"
10 #include "llvm/Support/raw_ostream.h" 10 #include "llvm/Support/raw_ostream.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 int ctor_score = dtor_score; 273 int ctor_score = dtor_score;
274 // You should be able to have 9 ints before we warn you. 274 // You should be able to have 9 ints before we warn you.
275 ctor_score += trivial_member; 275 ctor_score += trivial_member;
276 276
277 if (ctor_score >= 10) { 277 if (ctor_score >= 10) {
278 if (!record->hasUserDeclaredConstructor()) { 278 if (!record->hasUserDeclaredConstructor()) {
279 emitWarning(record_location, 279 emitWarning(record_location,
280 "Complex class/struct needs an explicit out-of-line " 280 "Complex class/struct needs an explicit out-of-line "
281 "constructor."); 281 "constructor.");
282 } else { 282 } else if (options_.check_implicit_copy_ctors) {
dcheng 2016/02/16 23:03:50 Since this flag is about implicit constructors, an
vmpstr 2016/02/16 23:13:27 The move ctor branch would have the same issues as
283 // Iterate across all the constructors in this file and yell if we 283 // Iterate across all the constructors in this file and yell if we
284 // find one that tries to be inline. 284 // find one that tries to be inline.
285 for (CXXRecordDecl::ctor_iterator it = record->ctor_begin(); 285 for (CXXRecordDecl::ctor_iterator it = record->ctor_begin();
286 it != record->ctor_end(); 286 it != record->ctor_end();
287 ++it) { 287 ++it) {
288 // The current check is buggy. An implicit copy constructor does not 288 // The current check is buggy. An implicit copy constructor does not
289 // have an inline body, so this check never fires for classes with a 289 // have an inline body, so this check never fires for classes with a
290 // user-declared out-of-line constructor. 290 // user-declared out-of-line constructor.
291 if (it->hasInlineBody()) { 291 if (it->hasInlineBody()) {
292 if (it->isCopyConstructor() && 292 if (it->isCopyConstructor() &&
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 // one of those, it means there is at least one member after a factory. 866 // one of those, it means there is at least one member after a factory.
867 if (weak_ptr_factory_location.isValid() && 867 if (weak_ptr_factory_location.isValid() &&
868 !param_is_weak_ptr_factory_to_self) { 868 !param_is_weak_ptr_factory_to_self) {
869 diagnostic().Report(weak_ptr_factory_location, 869 diagnostic().Report(weak_ptr_factory_location,
870 diag_weak_ptr_factory_order_); 870 diag_weak_ptr_factory_order_);
871 } 871 }
872 } 872 }
873 } 873 }
874 874
875 } // namespace chrome_checker 875 } // namespace chrome_checker
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698