From 8dedeb0230c589ca121098f8051a35eb5fb53848 Mon Sep 17 00:00:00 2001 From: Angel Garcia Gomez Date: Wed, 21 Oct 2015 12:58:15 +0000 Subject: Add modernize-use-default check to clang-tidy. Summary: Add a check that replaces empty bodies of special member functions with '= default;'. For now, it is only implemented for the default constructor and the destructor, which are the easier cases. The copy-constructor and the copy-assignment operator cases will be implemented later. I applied this check to the llvm code base and found 627 warnings (385 in llvm, 9 in compiler-rt, 220 in clang and 13 in clang-tools-extra). Applying the fixes didn't break any build or test, it only caused a -Wpedantic warning in lib/Target/Mips/MipsOptionRecord.h:33 becaused it replaced virtual ~MipsOptionRecord(){}; to virtual ~MipsOptionRecord()= default;; Reviewers: klimek Subscribers: george.burgess.iv, Eugene.Zelenko, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13871 llvm-svn: 250897 --- clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp') diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp index b780cb8aca5..d7463abf30f 100644 --- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp @@ -16,6 +16,7 @@ #include "ReplaceAutoPtrCheck.h" #include "ShrinkToFitCheck.h" #include "UseAutoCheck.h" +#include "UseDefaultCheck.h" #include "UseNullptrCheck.h" #include "UseOverrideCheck.h" @@ -29,13 +30,13 @@ class ModernizeModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck("modernize-loop-convert"); - CheckFactories.registerCheck( - "modernize-make-unique"); + CheckFactories.registerCheck("modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); CheckFactories.registerCheck( "modernize-replace-auto-ptr"); CheckFactories.registerCheck("modernize-shrink-to-fit"); CheckFactories.registerCheck("modernize-use-auto"); + CheckFactories.registerCheck("modernize-use-default"); CheckFactories.registerCheck("modernize-use-nullptr"); CheckFactories.registerCheck("modernize-use-override"); } @@ -45,7 +46,7 @@ public: auto &Opts = Options.CheckOptions; Opts["modernize-loop-convert.MinConfidence"] = "reasonable"; Opts["modernize-loop-convert.NamingStyle"] = "CamelCase"; - Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google". + Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google". Opts["modernize-replace-auto-ptr.IncludeStyle"] = "llvm"; // Also: "google". // Comma-separated list of macros that behave like NULL. -- cgit v1.2.3