diff options
author | Mads Ravn <madsravn@gmail.com> | 2016-08-26 05:59:53 +0000 |
---|---|---|
committer | Mads Ravn <madsravn@gmail.com> | 2016-08-26 05:59:53 +0000 |
commit | 041b804a9f0097953d3767196fc539d2940ecde4 (patch) | |
tree | 8fd5ac3848d1bc4a221946a2bbf6e9968c4e48a9 /clang-tools-extra/clang-tidy/llvm | |
parent | 510911f7bd7406ec7cd3b4d32349537f5448e578 (diff) | |
download | bcm5719-llvm-041b804a9f0097953d3767196fc539d2940ecde4.tar.gz bcm5719-llvm-041b804a9f0097953d3767196fc539d2940ecde4.zip |
[clang-tidy] Added hh, hxx and hpp to header guard checks.
Changed the extension check to include the option of ",h,hh,hpp,hxx" instead of just returning whether the file ended with ".h".
Differential revision: https://reviews.llvm.org/D20512
llvm-svn: 279803
Diffstat (limited to 'clang-tools-extra/clang-tidy/llvm')
-rw-r--r-- | clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp | 4 | ||||
-rw-r--r-- | clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h | 19 |
2 files changed, 20 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp index c44abbd9b5a..f0984b0e8c6 100644 --- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp @@ -13,8 +13,8 @@ namespace clang { namespace tidy { namespace llvm { -bool LLVMHeaderGuardCheck::shouldFixHeaderGuard(StringRef Filename) { - return Filename.endswith(".h"); +bool LLVMHeaderGuardCheck::shouldFixHeaderGuard(StringRef FileName) { + return utils::isHeaderFileExtension(FileName, HeaderFileExtensions); } std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename, diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h index f13dd5b1e99..76aaf5f56c7 100644 --- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h +++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h @@ -17,13 +17,30 @@ namespace tidy { namespace llvm { /// Finds and fixes header guards that do not adhere to LLVM style. +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/llvm-header-guard.html +/// The check supports these options: +/// - `HeaderFileExtensions`: a comma-separated list of filename extensions of +/// header files (The filename extension should not contain "." prefix). +/// ",h,hh,hpp,hxx" by default. +/// For extension-less header files, using an empty string or leaving an +/// empty string between "," if there are other filename extensions. class LLVMHeaderGuardCheck : public utils::HeaderGuardCheck { public: LLVMHeaderGuardCheck(StringRef Name, ClangTidyContext *Context) - : HeaderGuardCheck(Name, Context) {} + : HeaderGuardCheck(Name, Context), + RawStringHeaderFileExtensions( + Options.getLocalOrGlobal("HeaderFileExtensions", ",h,hh,hpp,hxx")) { + utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions, + HeaderFileExtensions, ','); + } bool shouldSuggestEndifComment(StringRef Filename) override { return false; } bool shouldFixHeaderGuard(StringRef Filename) override; std::string getHeaderGuard(StringRef Filename, StringRef OldGuard) override; + +private: + std::string RawStringHeaderFileExtensions; + utils::HeaderFileExtensionsSet HeaderFileExtensions; }; } // namespace llvm |