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

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

Issue 14064011: Add url/ to banned_directories in clang style checker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: behind a flag Created 7 years, 8 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 | « tools/clang/plugins/ChromeClassTester.cpp ('k') | no next file » | 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (const TypedefType* typedefed = dyn_cast<TypedefType>(type)) 68 if (const TypedefType* typedefed = dyn_cast<TypedefType>(type))
69 return UnwrapType(typedefed->desugar().getTypePtr()); 69 return UnwrapType(typedefed->desugar().getTypePtr());
70 return type; 70 return type;
71 } 71 }
72 72
73 // Searches for constructs that we know we don't want in the Chromium code base. 73 // Searches for constructs that we know we don't want in the Chromium code base.
74 class FindBadConstructsConsumer : public ChromeClassTester { 74 class FindBadConstructsConsumer : public ChromeClassTester {
75 public: 75 public:
76 FindBadConstructsConsumer(CompilerInstance& instance, 76 FindBadConstructsConsumer(CompilerInstance& instance,
77 bool check_base_classes, 77 bool check_base_classes,
78 bool check_virtuals_in_implementations) 78 bool check_virtuals_in_implementations,
79 : ChromeClassTester(instance), 79 bool check_url_directory)
80 : ChromeClassTester(instance, check_url_directory),
80 check_base_classes_(check_base_classes), 81 check_base_classes_(check_base_classes),
81 check_virtuals_in_implementations_(check_virtuals_in_implementations) { 82 check_virtuals_in_implementations_(check_virtuals_in_implementations),
83 check_url_directory_(check_url_directory) {
Nico 2013/04/16 15:31:11 Do you need this part? You're already passing this
82 // Register warning/error messages. 84 // Register warning/error messages.
83 diag_method_requires_override_ = diagnostic().getCustomDiagID( 85 diag_method_requires_override_ = diagnostic().getCustomDiagID(
84 getErrorLevel(), kMethodRequiresOverride); 86 getErrorLevel(), kMethodRequiresOverride);
85 diag_method_requires_virtual_ = diagnostic().getCustomDiagID( 87 diag_method_requires_virtual_ = diagnostic().getCustomDiagID(
86 getErrorLevel(), kMethodRequiresVirtual); 88 getErrorLevel(), kMethodRequiresVirtual);
87 diag_no_explicit_dtor_ = diagnostic().getCustomDiagID( 89 diag_no_explicit_dtor_ = diagnostic().getCustomDiagID(
88 getErrorLevel(), kNoExplicitDtor); 90 getErrorLevel(), kNoExplicitDtor);
89 diag_public_dtor_ = diagnostic().getCustomDiagID( 91 diag_public_dtor_ = diagnostic().getCustomDiagID(
90 getErrorLevel(), kPublicDtor); 92 getErrorLevel(), kPublicDtor);
91 diag_protected_non_virtual_dtor_ = diagnostic().getCustomDiagID( 93 diag_protected_non_virtual_dtor_ = diagnostic().getCustomDiagID(
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 PrintInheritanceChain(*it); 614 PrintInheritanceChain(*it);
613 } 615 }
614 } 616 }
615 } 617 }
616 }; 618 };
617 619
618 class FindBadConstructsAction : public PluginASTAction { 620 class FindBadConstructsAction : public PluginASTAction {
619 public: 621 public:
620 FindBadConstructsAction() 622 FindBadConstructsAction()
621 : check_base_classes_(false), 623 : check_base_classes_(false),
622 check_virtuals_in_implementations_(true) { 624 check_virtuals_in_implementations_(true),
625 check_url_directory_(false) {
623 } 626 }
624 627
625 protected: 628 protected:
626 // Overridden from PluginASTAction: 629 // Overridden from PluginASTAction:
627 virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance, 630 virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance,
628 llvm::StringRef ref) { 631 llvm::StringRef ref) {
629 return new FindBadConstructsConsumer( 632 return new FindBadConstructsConsumer(
630 instance, check_base_classes_, check_virtuals_in_implementations_); 633 instance, check_base_classes_, check_virtuals_in_implementations_,
634 check_url_directory_);
631 } 635 }
632 636
633 virtual bool ParseArgs(const CompilerInstance& instance, 637 virtual bool ParseArgs(const CompilerInstance& instance,
634 const std::vector<std::string>& args) { 638 const std::vector<std::string>& args) {
635 bool parsed = true; 639 bool parsed = true;
636 640
637 for (size_t i = 0; i < args.size() && parsed; ++i) { 641 for (size_t i = 0; i < args.size() && parsed; ++i) {
638 if (args[i] == "skip-virtuals-in-implementations") { 642 if (args[i] == "skip-virtuals-in-implementations") {
639 // TODO(rsleevi): Remove this once http://crbug.com/115047 is fixed. 643 // TODO(rsleevi): Remove this once http://crbug.com/115047 is fixed.
640 check_virtuals_in_implementations_ = false; 644 check_virtuals_in_implementations_ = false;
641 } else if (args[i] == "check-base-classes") { 645 } else if (args[i] == "check-base-classes") {
642 // TODO(rsleevi): Remove this once http://crbug.com/123295 is fixed. 646 // TODO(rsleevi): Remove this once http://crbug.com/123295 is fixed.
643 check_base_classes_ = true; 647 check_base_classes_ = true;
648 } else if (args[i] == "check-url-directory") {
649 // TODO(tfarina): Remove this once http://crbug.com/229660 is fixed.
650 check_url_directory_ = true;
644 } else { 651 } else {
645 parsed = false; 652 parsed = false;
646 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n"; 653 llvm::errs() << "Unknown clang plugin argument: " << args[i] << "\n";
647 } 654 }
648 } 655 }
649 656
650 return parsed; 657 return parsed;
651 } 658 }
652 659
653 private: 660 private:
654 bool check_base_classes_; 661 bool check_base_classes_;
655 bool check_virtuals_in_implementations_; 662 bool check_virtuals_in_implementations_;
663 bool check_url_directory_;
656 }; 664 };
657 665
658 } // namespace 666 } // namespace
659 667
660 static FrontendPluginRegistry::Add<FindBadConstructsAction> 668 static FrontendPluginRegistry::Add<FindBadConstructsAction>
661 X("find-bad-constructs", "Finds bad C++ constructs"); 669 X("find-bad-constructs", "Finds bad C++ constructs");
OLDNEW
« no previous file with comments | « tools/clang/plugins/ChromeClassTester.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698