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

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

Issue 11143020: roll clang 163674:165787 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: warn :-/ Created 8 years, 2 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
« no previous file with comments | « build/common.gypi ('k') | tools/clang/scripts/plugin_flags.sh » ('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 // This file defines a bunch of recurring problems in the Chromium C++ code. 5 // This file defines a bunch of recurring problems in the Chromium C++ code.
6 // 6 //
7 // Checks that are implemented: 7 // Checks that are implemented:
8 // - Constructors/Destructors should not be inlined if they are of a complex 8 // - Constructors/Destructors should not be inlined if they are of a complex
9 // class type. 9 // class type.
10 // - Missing "virtual" keywords on methods that should be virtual. 10 // - Missing "virtual" keywords on methods that should be virtual.
(...skipping 11 matching lines...) Expand all
22 #include "clang/Frontend/CompilerInstance.h" 22 #include "clang/Frontend/CompilerInstance.h"
23 #include "llvm/Support/raw_ostream.h" 23 #include "llvm/Support/raw_ostream.h"
24 24
25 #include "ChromeClassTester.h" 25 #include "ChromeClassTester.h"
26 26
27 using namespace clang; 27 using namespace clang;
28 28
29 namespace { 29 namespace {
30 30
31 bool TypeHasNonTrivialDtor(const Type* type) { 31 bool TypeHasNonTrivialDtor(const Type* type) {
32 if (const CXXRecordDecl* cxx_r = type->getCXXRecordDeclForPointerType()) 32 if (const CXXRecordDecl* cxx_r = type->getPointeeCXXRecordDecl())
33 return cxx_r->hasTrivialDestructor(); 33 return cxx_r->hasTrivialDestructor();
34 34
35 return false; 35 return false;
36 } 36 }
37 37
38 // Returns the underlying Type for |type| by expanding typedefs and removing 38 // Returns the underlying Type for |type| by expanding typedefs and removing
39 // any namespace qualifiers. 39 // any namespace qualifiers.
40 const Type* UnwrapType(const Type* type) { 40 const Type* UnwrapType(const Type* type) {
41 if (const ElaboratedType* elaborated = dyn_cast<ElaboratedType>(type)) 41 if (const ElaboratedType* elaborated = dyn_cast<ElaboratedType>(type))
42 return UnwrapType(elaborated->getNamedType().getTypePtr()); 42 return UnwrapType(elaborated->getNamedType().getTypePtr());
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 const std::vector<std::string>& args) { 410 const std::vector<std::string>& args) {
411 bool parsed = true; 411 bool parsed = true;
412 412
413 for (size_t i = 0; i < args.size() && parsed; ++i) { 413 for (size_t i = 0; i < args.size() && parsed; ++i) {
414 if (args[i] == "skip-refcounted-dtors") { 414 if (args[i] == "skip-refcounted-dtors") {
415 check_refcounted_dtors_ = false; 415 check_refcounted_dtors_ = false;
416 } else if (args[i] == "skip-virtuals-in-implementations") { 416 } else if (args[i] == "skip-virtuals-in-implementations") {
417 check_virtuals_in_implementations_ = false; 417 check_virtuals_in_implementations_ = false;
418 } else { 418 } else {
419 parsed = false; 419 parsed = false;
420 llvm::errs() << "Unknown argument: " << args[i] << "\n"; 420 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n";
Nico 2012/10/15 21:48:27 Note: I made this change before building the packa
421 } 421 }
422 } 422 }
423 423
424 return parsed; 424 return parsed;
425 } 425 }
426 426
427 private: 427 private:
428 bool check_refcounted_dtors_; 428 bool check_refcounted_dtors_;
429 bool check_virtuals_in_implementations_; 429 bool check_virtuals_in_implementations_;
430 }; 430 };
431 431
432 } // namespace 432 } // namespace
433 433
434 static FrontendPluginRegistry::Add<FindBadConstructsAction> 434 static FrontendPluginRegistry::Add<FindBadConstructsAction>
435 X("find-bad-constructs", "Finds bad C++ constructs"); 435 X("find-bad-constructs", "Finds bad C++ constructs");
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | tools/clang/scripts/plugin_flags.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698