Prazek created this revision. Prazek added reviewers: alexfh, malcolm.parsons. Prazek added a subscriber: cfe-commits. Herald added subscribers: JDevlieghere, mgorny.
Module for checks for obvious bugs that probably won't be found in working code, but can be found while looking for an obvious bug in broken code. https://reviews.llvm.org/D27815 Files: clang-tidy/CMakeLists.txt clang-tidy/obvious/CMakeLists.txt clang-tidy/obvious/ObviousTidyModule.cpp clang-tidy/plugin/CMakeLists.txt clang-tidy/plugin/ClangTidyPlugin.cpp clang-tidy/tool/CMakeLists.txt clang-tidy/tool/ClangTidyMain.cpp docs/clang-tidy/index.rst
Index: docs/clang-tidy/index.rst =================================================================== --- docs/clang-tidy/index.rst +++ docs/clang-tidy/index.rst @@ -65,6 +65,9 @@ ``modernize-`` Checks that advocate usage of modern (currently "modern" means "C++11") language constructs. ``mpi-`` Checks related to MPI (Message Passing Interface). +``obvious-`` Checks for obvious bugs that probably won't be found + in working code, but can be found while looking for an + obvious bug in broken code. ``performance-`` Checks that target performance-related issues. ``readability-`` Checks that target readability-related issues that don't relate to any particular coding style. Index: clang-tidy/tool/ClangTidyMain.cpp =================================================================== --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -465,6 +465,11 @@ static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination = MPIModuleAnchorSource; +// This anchor is used to force the linker to link the ObviousModule. +extern volatile int ObviousModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ObviousModuleAnchorDestination = + ObviousModuleAnchorSource; + // This anchor is used to force the linker to link the PerformanceModule. extern volatile int PerformanceModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination = Index: clang-tidy/tool/CMakeLists.txt =================================================================== --- clang-tidy/tool/CMakeLists.txt +++ clang-tidy/tool/CMakeLists.txt @@ -21,6 +21,7 @@ clangTidyMiscModule clangTidyModernizeModule clangTidyMPIModule + clangTidyObviousModule clangTidyPerformanceModule clangTidyReadabilityModule clangTooling Index: clang-tidy/plugin/ClangTidyPlugin.cpp =================================================================== --- clang-tidy/plugin/ClangTidyPlugin.cpp +++ clang-tidy/plugin/ClangTidyPlugin.cpp @@ -108,6 +108,11 @@ static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination = ModernizeModuleAnchorSource; +// This anchor is used to force the linker to link the ObviousModule. +extern volatile int ObviousModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ObviousModuleAnchorDestination = + ObviousModuleAnchorSource; + // This anchor is used to force the linker to link the PerformanceModule. extern volatile int PerformanceModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination = Index: clang-tidy/plugin/CMakeLists.txt =================================================================== --- clang-tidy/plugin/CMakeLists.txt +++ clang-tidy/plugin/CMakeLists.txt @@ -15,6 +15,7 @@ clangTidyLLVMModule clangTidyMiscModule clangTidyModernizeModule + clangTidyObviousModule clangTidyMPIModule clangTidyPerformanceModule clangTidyReadabilityModule Index: clang-tidy/obvious/ObviousTidyModule.cpp =================================================================== --- /dev/null +++ clang-tidy/obvious/ObviousTidyModule.cpp @@ -0,0 +1,38 @@ +//===------- ObviousTidyModule.cpp - clang-tidy ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "../ClangTidy.h" +#include "../ClangTidyModule.h" +#include "../ClangTidyModuleRegistry.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace obvious { + +class ObviousModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + // Add obvious checks here. + } +}; + +// Register the ObviousModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add<ObviousModule> X("obvious-module", + "Add obvious checks."); + +} // namespace obvious + +// This anchor is used to force the linker to link in the generated object file +// and thus register the ObviousModule. +volatile int ObviousModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang Index: clang-tidy/obvious/CMakeLists.txt =================================================================== --- /dev/null +++ clang-tidy/obvious/CMakeLists.txt @@ -0,0 +1,13 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_library(clangTidyObviousModule + ObviousTidyModule.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangLex + clangTidy + clangTidyUtils + ) Index: clang-tidy/CMakeLists.txt =================================================================== --- clang-tidy/CMakeLists.txt +++ clang-tidy/CMakeLists.txt @@ -36,6 +36,7 @@ add_subdirectory(misc) add_subdirectory(modernize) add_subdirectory(mpi) +add_subdirectory(obvious) add_subdirectory(performance) add_subdirectory(readability) add_subdirectory(utils)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits