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

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

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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
« no previous file with comments | « third_party/yasm/yasm.gyp ('k') | tools/clang/plugins/tests/inline_ctor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (it->hasInlineBody()) { 289 if (it->hasInlineBody()) {
290 if (it->isCopyConstructor() && 290 if (it->isCopyConstructor() &&
291 !record->hasUserDeclaredCopyConstructor()) { 291 !record->hasUserDeclaredCopyConstructor()) {
292 emitWarning(record_location, 292 emitWarning(record_location,
293 "Complex class/struct needs an explicit out-of-line " 293 "Complex class/struct needs an explicit out-of-line "
294 "copy constructor."); 294 "copy constructor.");
295 } else { 295 } else {
296 emitWarning(it->getInnerLocStart(), 296 emitWarning(it->getInnerLocStart(),
297 "Complex constructor has an inlined body."); 297 "Complex constructor has an inlined body.");
298 } 298 }
299 } else if (it->isInlined() && (!it->isCopyOrMoveConstructor() || 299 } else if (it->isInlined() && !it->isInlineSpecified() &&
300 it->isExplicitlyDefaulted())) { 300 !it->isDeleted() && (!it->isCopyOrMoveConstructor() ||
301 it->isExplicitlyDefaulted())) {
301 // isInlined() is a more reliable check than hasInlineBody(), but 302 // isInlined() is a more reliable check than hasInlineBody(), but
302 // unfortunately, it results in warnings for implicit copy/move 303 // unfortunately, it results in warnings for implicit copy/move
303 // constructors in the previously mentioned situation. To preserve 304 // constructors in the previously mentioned situation. To preserve
304 // compatibility with existing Chromium code, only warn if it's an 305 // compatibility with existing Chromium code, only warn if it's an
305 // explicitly defaulted copy or move constructor. 306 // explicitly defaulted copy or move constructor.
306 emitWarning(it->getInnerLocStart(), 307 emitWarning(it->getInnerLocStart(),
307 "Complex constructor has an inlined body."); 308 "Complex constructor has an inlined body.");
308 } 309 }
309 } 310 }
310 } 311 }
311 } 312 }
312 313
313 // The destructor side is equivalent except that we don't check for 314 // The destructor side is equivalent except that we don't check for
314 // trivial members; 20 ints don't need a destructor. 315 // trivial members; 20 ints don't need a destructor.
315 if (dtor_score >= 10 && !record->hasTrivialDestructor()) { 316 if (dtor_score >= 10 && !record->hasTrivialDestructor()) {
316 if (!record->hasUserDeclaredDestructor()) { 317 if (!record->hasUserDeclaredDestructor()) {
317 emitWarning(record_location, 318 emitWarning(record_location,
318 "Complex class/struct needs an explicit out-of-line " 319 "Complex class/struct needs an explicit out-of-line "
319 "destructor."); 320 "destructor.");
320 } else if (CXXDestructorDecl* dtor = record->getDestructor()) { 321 } else if (CXXDestructorDecl* dtor = record->getDestructor()) {
321 if (dtor->isInlined()) { 322 if (dtor->isInlined() && !dtor->isInlineSpecified() &&
323 !dtor->isDeleted()) {
322 emitWarning(dtor->getInnerLocStart(), 324 emitWarning(dtor->getInnerLocStart(),
323 "Complex destructor has an inline body."); 325 "Complex destructor has an inline body.");
324 } 326 }
325 } 327 }
326 } 328 }
327 } 329 }
328 330
329 bool FindBadConstructsConsumer::InTestingNamespace(const Decl* record) { 331 bool FindBadConstructsConsumer::InTestingNamespace(const Decl* record) {
330 return GetNamespace(record).find("testing") != std::string::npos; 332 return GetNamespace(record).find("testing") != std::string::npos;
331 } 333 }
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 // one of those, it means there is at least one member after a factory. 787 // one of those, it means there is at least one member after a factory.
786 if (weak_ptr_factory_location.isValid() && 788 if (weak_ptr_factory_location.isValid() &&
787 !param_is_weak_ptr_factory_to_self) { 789 !param_is_weak_ptr_factory_to_self) {
788 diagnostic().Report(weak_ptr_factory_location, 790 diagnostic().Report(weak_ptr_factory_location,
789 diag_weak_ptr_factory_order_); 791 diag_weak_ptr_factory_order_);
790 } 792 }
791 } 793 }
792 } 794 }
793 795
794 } // namespace chrome_checker 796 } // namespace chrome_checker
OLDNEW
« no previous file with comments | « third_party/yasm/yasm.gyp ('k') | tools/clang/plugins/tests/inline_ctor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698