From 498cce575f348ae645561665fcfd0d5ef83280db Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 13 Aug 2014 13:57:57 +0000 Subject: [clang-tidy] Add a generic header guard checker + LLVM implementation. The implementation is split into a generic part and a LLVM-specific part. Other codebases can implement it with their own style. The specific features supported are: - Verification (and fixing) of header guards against a style based on the file path - Automatic insertion of header guards for headers that are missing them - A warning when the header guard doesn't enable our fancy header guard optimization (e.g. when there's an include preceeding the guard) - Automatic insertion of a comment with the guard name after #endif. For the LLVM style we disable #endif comments for now, they're not very common in the codebase. We also only flag headers in the include directories, there doesn't seem to be a common style outside. Differential Revision: http://reviews.llvm.org/D4867 llvm-svn: 215548 --- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp') diff --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp index 0586525228b..a8ef6299028 100644 --- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp @@ -10,6 +10,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "HeaderGuardCheck.h" #include "IncludeOrderCheck.h" #include "NamespaceCommentCheck.h" #include "TwineLocalCheck.h" @@ -20,6 +21,8 @@ namespace tidy { class LLVMModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + CheckFactories.addCheckFactory( + "llvm-header-guard", new ClangTidyCheckFactory()); CheckFactories.addCheckFactory( "llvm-include-order", new ClangTidyCheckFactory()); CheckFactories.addCheckFactory( -- cgit v1.2.3