PiotrZSL updated this revision to Diff 509410. PiotrZSL added a comment. Move fix from note to warning
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146875/new/ https://reviews.llvm.org/D146875 Files: clang-tools-extra/clang-tidy/add_new_check.py clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp Index: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -18,6 +18,7 @@ #include "BranchCloneCheck.h" #include "CopyConstructorInitCheck.h" #include "DanglingHandleCheck.h" +#include "DupaCheck.h" #include "DynamicStaticInitializersCheck.h" #include "EasilySwappableParametersCheck.h" #include "ExceptionEscapeCheck.h" @@ -98,6 +99,8 @@ "bugprone-copy-constructor-init"); CheckFactories.registerCheck<DanglingHandleCheck>( "bugprone-dangling-handle"); + CheckFactories.registerCheck<DupaCheck>( + "bugprone-dupa"); CheckFactories.registerCheck<DynamicStaticInitializersCheck>( "bugprone-dynamic-static-initializers"); CheckFactories.registerCheck<EasilySwappableParametersCheck>( Index: clang-tools-extra/clang-tidy/add_new_check.py =================================================================== --- clang-tools-extra/clang-tidy/add_new_check.py +++ clang-tools-extra/clang-tidy/add_new_check.py @@ -138,9 +138,9 @@ if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_")) return; diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome") - << MatchedDecl; - diag(MatchedDecl->getLocation(), "insert 'awesome'", DiagnosticIDs::Note) + << MatchedDecl << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_"); + diag(MatchedDecl->getLocation(), "insert 'awesome'", DiagnosticIDs::Note); } } // namespace clang::tidy::%(namespace)s @@ -275,7 +275,7 @@ module, check_name + '.' + test_extension)) print('Creating %s...' % filename) with io.open(filename, 'w', encoding='utf8', newline='\n') as f: - f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t + f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t -- // FIXME: Add something that triggers the check here. void f(); @@ -293,7 +293,7 @@ def get_actual_filename(dirname, filename): - if not os.path.isdir(dirname): + if not os.path.isdir(dirname): return '' name = os.path.join(dirname, filename) if (os.path.isfile(name)):
Index: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp +++ clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp @@ -18,6 +18,7 @@ #include "BranchCloneCheck.h" #include "CopyConstructorInitCheck.h" #include "DanglingHandleCheck.h" +#include "DupaCheck.h" #include "DynamicStaticInitializersCheck.h" #include "EasilySwappableParametersCheck.h" #include "ExceptionEscapeCheck.h" @@ -98,6 +99,8 @@ "bugprone-copy-constructor-init"); CheckFactories.registerCheck<DanglingHandleCheck>( "bugprone-dangling-handle"); + CheckFactories.registerCheck<DupaCheck>( + "bugprone-dupa"); CheckFactories.registerCheck<DynamicStaticInitializersCheck>( "bugprone-dynamic-static-initializers"); CheckFactories.registerCheck<EasilySwappableParametersCheck>( Index: clang-tools-extra/clang-tidy/add_new_check.py =================================================================== --- clang-tools-extra/clang-tidy/add_new_check.py +++ clang-tools-extra/clang-tidy/add_new_check.py @@ -138,9 +138,9 @@ if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_")) return; diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome") - << MatchedDecl; - diag(MatchedDecl->getLocation(), "insert 'awesome'", DiagnosticIDs::Note) + << MatchedDecl << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_"); + diag(MatchedDecl->getLocation(), "insert 'awesome'", DiagnosticIDs::Note); } } // namespace clang::tidy::%(namespace)s @@ -275,7 +275,7 @@ module, check_name + '.' + test_extension)) print('Creating %s...' % filename) with io.open(filename, 'w', encoding='utf8', newline='\n') as f: - f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t + f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t -- // FIXME: Add something that triggers the check here. void f(); @@ -293,7 +293,7 @@ def get_actual_filename(dirname, filename): - if not os.path.isdir(dirname): + if not os.path.isdir(dirname): return '' name = os.path.join(dirname, filename) if (os.path.isfile(name)):
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits