From c2d7577cc552b248857253f99a401800bc010100 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 5 Feb 2016 11:23:59 +0000 Subject: [clang-tdiy] Add header file extension configuration support. Summary: * Add a `HeaderFileExtensions` check option in misc-definitions-in-headers, google-build-namespaces and google-global-names-in-headers. Reviewers: aaron.ballman, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16113 llvm-svn: 259879 --- .../clang-tidy/misc/DefinitionsInHeadersCheck.h | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h') diff --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h index 93956099b1b..428b05cd5ac 100644 --- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h +++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h @@ -11,20 +11,26 @@ #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DEFINITIONS_IN_HEADERS_H #include "../ClangTidy.h" +#include "../utils/HeaderFileExtensionsUtils.h" namespace clang { namespace tidy { namespace misc { -// Finds non-extern non-inline function and variable definitions in header -// files, which can lead to potential ODR violations. -// -// There is one option: -// - `UseHeaderFileExtension`: Whether to use file extension (h, hh, hpp, hxx) -// to distinguish header files. True by default. -// -// For the user-facing documentation see: -// http://clang.llvm.org/extra/clang-tidy/checks/misc-definitions-in-headers.html +/// Finds non-extern non-inline function and variable definitions in header +/// files, which can lead to potential ODR violations. +/// +/// The check supports these options: +/// - `UseHeaderFileExtension`: Whether to use file extension to distinguish +/// header files. True by default. +/// - `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. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/misc-definitions-in-headers.html class DefinitionsInHeadersCheck : public ClangTidyCheck { public: DefinitionsInHeadersCheck(StringRef Name, ClangTidyContext *Context); @@ -34,6 +40,8 @@ public: private: const bool UseHeaderFileExtension; + const std::string RawStringHeaderFileExtensions; + utils::HeaderFileExtensionsSet HeaderFileExtensions; }; } // namespace misc -- cgit v1.2.3