Index: clang-tidy/CMakeLists.txt =================================================================== --- clang-tidy/CMakeLists.txt +++ clang-tidy/CMakeLists.txt @@ -26,6 +26,7 @@ ) add_subdirectory(tool) +add_subdirectory(cert) add_subdirectory(llvm) add_subdirectory(google) add_subdirectory(misc) Index: clang-tidy/Makefile =================================================================== --- clang-tidy/Makefile +++ clang-tidy/Makefile @@ -11,6 +11,6 @@ LIBRARYNAME := clangTidy include $(CLANG_LEVEL)/../../Makefile.config -DIRS = utils readability llvm google misc modernize tool +DIRS = utils cert readability llvm google misc modernize tool include $(CLANG_LEVEL)/Makefile Index: clang-tidy/cert/CERTTidyModule.cpp =================================================================== --- clang-tidy/cert/CERTTidyModule.cpp +++ clang-tidy/cert/CERTTidyModule.cpp @@ -0,0 +1,59 @@ +//===--- CERTTidyModule.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" +#include "../google/UnnamedNamespaceInHeaderCheck.h" +#include "../misc/MoveConstructorInitCheck.h" +#include "../misc/NewDeleteOverloadsCheck.h" +#include "../misc/NonCopyableObjects.h" +#include "../misc/StaticAssertCheck.h" + +namespace clang { +namespace tidy { +namespace CERT { + +class CERTModule : public ClangTidyModule { +public: + void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + // C++ checkers + // DCL + CheckFactories.registerCheck( + "cert-dcl54-cpp"); + CheckFactories.registerCheck( + "cert-dcl59-cpp"); + // OOP + CheckFactories.registerCheck( + "cert-oop11-cpp"); + + // C checkers + // DCL + CheckFactories.registerCheck( + "cert-dcl03-c"); + + // FIO + CheckFactories.registerCheck( + "cert-fio38-c"); + } +}; + +} // namespace misc + +// Register the MiscTidyModule using this statically initialized variable. +static ClangTidyModuleRegistry::Add +X("cert-module", + "Adds lint checks corresponding to CERT secure coding guidelines."); + +// This anchor is used to force the linker to link in the generated object file +// and thus register the CERTModule. +volatile int CERTModuleAnchorSource = 0; + +} // namespace tidy +} // namespace clang Index: clang-tidy/cert/CMakeLists.txt =================================================================== --- clang-tidy/cert/CMakeLists.txt +++ clang-tidy/cert/CMakeLists.txt @@ -0,0 +1,12 @@ +set(LLVM_LINK_COMPONENTS support) + +add_clang_library(clangTidyCERTModule + CERTTidyModule.cpp + + LINK_LIBS + clangAST + clangASTMatchers + clangBasic + clangLex + clangTidy + ) Index: clang-tidy/cert/Makefile =================================================================== --- clang-tidy/cert/Makefile +++ clang-tidy/cert/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/misc/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyCERTModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/tool/CMakeLists.txt =================================================================== --- clang-tidy/tool/CMakeLists.txt +++ clang-tidy/tool/CMakeLists.txt @@ -10,6 +10,7 @@ clangASTMatchers clangBasic clangTidy + clangTidyCERTModule clangTidyGoogleModule clangTidyLLVMModule clangTidyMiscModule Index: clang-tidy/tool/ClangTidyMain.cpp =================================================================== --- clang-tidy/tool/ClangTidyMain.cpp +++ clang-tidy/tool/ClangTidyMain.cpp @@ -347,6 +347,11 @@ return 0; } +// This anchor is used to force the linker to link the CERTModule. +extern volatile int CERTModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination = + CERTModuleAnchorSource; + // This anchor is used to force the linker to link the LLVMModule. extern volatile int LLVMModuleAnchorSource; static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination = Index: clang-tidy/tool/Makefile =================================================================== --- clang-tidy/tool/Makefile +++ clang-tidy/tool/Makefile @@ -16,8 +16,9 @@ include $(CLANG_LEVEL)/../../Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option -USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \ - clangTidyMiscModule.a clangTidyModernizeModule.a clangTidyReadability.a \ +USEDLIBS = clangTidy.a clangTidyCERTModule.a clangTidyLLVMModule.a \ + clangTidyGoogleModule.a \ clangTidyMiscModule.a \ + clangTidyModernizeModule.a clangTidyReadability.a \ clangTidyUtils.a clangStaticAnalyzerFrontend.a \ clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \ clangFormat.a clangASTMatchers.a clangTooling.a clangToolingCore.a \