carlosgalvezp updated this revision to Diff 487191. carlosgalvezp added a comment.
- Add also ImplementationFileExtensions. - Add deprecation notice to affected checks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141000/new/ https://reviews.llvm.org/D141000 Files: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp clang-tools-extra/clang-tidy/ClangTidyOptions.h clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst clang-tools-extra/docs/clang-tidy/index.rst clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp +++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp @@ -75,13 +75,20 @@ TEST(ParseConfiguration, ValidConfiguration) { llvm::ErrorOr<ClangTidyOptions> Options = - parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n" - "HeaderFilterRegex: \".*\"\n" - "AnalyzeTemporaryDtors: true\n" - "User: some.user", - "Options")); + parseConfiguration(llvm::MemoryBufferRef( + "Checks: \"-*,misc-*\"\n" + "HeaderFileExtensions: [\"h\",\"hh\",\"hpp\",\"hxx\"]\n" + "ImplementationFileExtensions: [\"c\",\"cc\",\"cpp\",\"cxx\"]\n" + "HeaderFilterRegex: \".*\"\n" + "AnalyzeTemporaryDtors: true\n" + "User: some.user", + "Options")); EXPECT_TRUE(!!Options); EXPECT_EQ("-*,misc-*", *Options->Checks); + EXPECT_EQ(std::vector<std::string>({"h", "hh", "hpp", "hxx"}), + *Options->HeaderFileExtensions); + EXPECT_EQ(std::vector<std::string>({"c", "cc", "cpp", "cxx"}), + *Options->ImplementationFileExtensions); EXPECT_EQ(".*", *Options->HeaderFilterRegex); EXPECT_EQ("some.user", *Options->User); } @@ -104,6 +111,8 @@ llvm::ErrorOr<ClangTidyOptions> Options1 = parseConfiguration(llvm::MemoryBufferRef(R"( Checks: "check1,check2" + HeaderFileExtensions: ["h","hh"] + ImplementationFileExtensions: ["c","cc"] HeaderFilterRegex: "filter1" AnalyzeTemporaryDtors: true User: user1 @@ -116,6 +125,8 @@ llvm::ErrorOr<ClangTidyOptions> Options2 = parseConfiguration(llvm::MemoryBufferRef(R"( Checks: "check3,check4" + HeaderFileExtensions: ["hpp","hxx"] + ImplementationFileExtensions: ["cpp","cxx"] HeaderFilterRegex: "filter2" AnalyzeTemporaryDtors: false User: user2 @@ -127,6 +138,10 @@ ASSERT_TRUE(!!Options2); ClangTidyOptions Options = Options1->merge(*Options2, 0); EXPECT_EQ("check1,check2,check3,check4", *Options.Checks); + EXPECT_EQ(std::vector<std::string>({"hpp", "hxx"}), + *Options.HeaderFileExtensions); + EXPECT_EQ(std::vector<std::string>({"cpp", "cxx"}), + *Options.ImplementationFileExtensions); EXPECT_EQ("filter2", *Options.HeaderFilterRegex); EXPECT_EQ("user2", *Options.User); ASSERT_TRUE(Options.ExtraArgs.has_value()); Index: clang-tools-extra/docs/clang-tidy/index.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/index.rst +++ clang-tools-extra/docs/clang-tidy/index.rst @@ -139,7 +139,7 @@ When the value is empty, clang-tidy will attempt to find a file named .clang-tidy for each source file in its parent directories. - --config-file=<string> - + --config-file=<string> - Specify the path of .clang-tidy or custom config file: e.g. --config-file=/some/path/myTidyConfigFile This option internally works exactly the same way as @@ -237,7 +237,7 @@ format to stderr. When this option is passed, these per-TU profiles are instead stored as JSON. --system-headers - Display the errors from system headers. - --use-color - + --use-color - Use colors in diagnostics. If not set, colors will be used if the terminal connected to standard output supports colors. @@ -287,12 +287,14 @@ $ clang-tidy -dump-config --- - Checks: '-*,some-check' - WarningsAsErrors: '' - HeaderFilterRegex: '' - FormatStyle: none - InheritParentConfig: true - User: user + Checks: '-*,some-check' + WarningsAsErrors: '' + HeaderFileExtensions: ['h','hh','hpp','hxx'] + ImplementationFileExtensions: ['c','cc','cpp','cxx'] + HeaderFilterRegex: '' + FormatStyle: none + InheritParentConfig: true + User: user CheckOptions: some-check.SomeOption: 'some value' ... Index: clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst +++ clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst @@ -38,6 +38,9 @@ .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + A semicolon-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is ";h;hh;hpp;hxx". For extension-less header files, using an empty string or leaving an Index: clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst +++ clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst @@ -22,6 +22,9 @@ .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + A semicolon-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For extension-less header files, use an empty string or leave an Index: clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst +++ clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst @@ -92,6 +92,9 @@ .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no @@ -100,5 +103,8 @@ .. option:: UseHeaderFileExtension + Note: this option is deprecated, it will be removed in clang-tidy 18. + The check will unconditionally use the global option `HeaderFileExtensions`. + When `true`, the check will use the file extension to distinguish header files. Default is `true`. Index: clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst +++ clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst @@ -10,6 +10,9 @@ .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no Index: clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst +++ clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst @@ -14,6 +14,9 @@ .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + A comma-separated list of filename extensions of header files (the filename extensions should not contain "." prefix). Default is "h". For header files without an extension, use an empty string (if there are no Index: clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst +++ clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst @@ -17,6 +17,9 @@ .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst +++ clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst @@ -19,6 +19,9 @@ ------- .. option:: HeaderFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `HeaderFileExtensions`. + Default value: ``";h;hh;hpp;hxx"`` A semicolon-separated list of filename extensions of header files (the filename extensions should not contain a "." prefix). For extension-less @@ -27,6 +30,9 @@ .. option:: ImplementationFileExtensions + Note: this option is deprecated, it will be removed in clang-tidy 18. + Please use the global configuration option `ImplementationFileExtensions`. + Default value: ``"c;cc;cpp;cxx"`` Likewise, a semicolon-separated list of filename extensions of implementation files. Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -99,6 +99,12 @@ - Change to Python 3 in the shebang of `add_new_check.py` and `rename_check.py`, as the existing code is not compatible with Python 2. +- New global configuration file option `HeaderFileExtensions`, replacing the check-local + option of the same name. + +- New global configuration file option `ImplementationFileExtensions`, replacing the check-local + option of the same name. + New checks ^^^^^^^^^^ @@ -145,11 +151,21 @@ <clang-tidy/checks/bugprone/assignment-in-if-condition>` check when there was an assignement in a lambda found in the condition of an ``if``. +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`bugprone-dynamic-static-initializers + <clang-tidy/checks/bugprone/dynamic-static-initializers>` check. + Global options of the same name should be used instead. + - Improved :doc:`bugprone-signal-handler <clang-tidy/checks/bugprone/signal-handler>` check. Partial support for C++14 signal handler rules was added. Bug report generation was improved. +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`bugprone-suspicious-include + <clang-tidy/checks/bugprone/suspicious-include>` check. + Global options of the same name should be used instead. + - Fixed a false positive in :doc:`cppcoreguidelines-pro-type-member-init <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` when warnings would be emitted for uninitialized members of an anonymous union despite @@ -159,6 +175,31 @@ <clang-tidy/checks/google/objc-avoid-throwing-exception>` check for exceptions thrown by code emitted from macros in system headers. +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`google-build-namespaces + <clang-tidy/checks/google/build-namespaces>` check. + Global options of the same name should be used instead. + +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`google-global-names-in-headers + <clang-tidy/checks/google/global-names-in-headers>` check. + Global options of the same name should be used instead. + +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`llvm-header-guard + <clang-tidy/checks/llvm/header-guard>` check. + Global options of the same name should be used instead. + +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`misc-definitions-in-headers + <clang-tidy/checks/misc/definitions-in-headers>` check. + Global options of the same name should be used instead. + +- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions` + in :doc:`misc-unused-using-decls + <clang-tidy/checks/misc/misc-unused-using-decls>` check. + Global options of the same name should be used instead. + - Improved :doc:`modernize-use-emplace <clang-tidy/checks/modernize/use-emplace>` check. Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp =================================================================== --- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -46,12 +46,14 @@ $ clang-tidy -dump-config --- - Checks: '-*,some-check' - WarningsAsErrors: '' - HeaderFilterRegex: '' - FormatStyle: none - InheritParentConfig: true - User: user + Checks: '-*,some-check' + WarningsAsErrors: '' + HeaderFileExtensions: ['h','hh','hpp','hxx'] + ImplementationFileExtensions: ['c','cc','cpp','cxx'] + HeaderFilterRegex: '' + FormatStyle: none + InheritParentConfig: true + User: user CheckOptions: some-check.SomeOption: 'some value' ... @@ -130,10 +132,10 @@ cl::init(false), cl::cat(ClangTidyCategory)); static cl::opt<bool> FixNotes("fix-notes", cl::desc(R"( -If a warning has no fix, but a single fix can -be found through an associated diagnostic note, -apply the fix. -Specifying this flag will implicitly enable the +If a warning has no fix, but a single fix can +be found through an associated diagnostic note, +apply the fix. +Specifying this flag will implicitly enable the '--fix' flag. )"), cl::init(false), cl::cat(ClangTidyCategory)); Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyOptions.h +++ clang-tools-extra/clang-tidy/ClangTidyOptions.h @@ -72,6 +72,14 @@ /// WarningsAsErrors filter. std::optional<std::string> WarningsAsErrors; + /// File extensions to consider to determine if a given diagnostic is located + /// in a header file. + std::optional<std::vector<std::string>> HeaderFileExtensions; + + /// File extensions to consider to determine if a given diagnostic is located + /// is located in an implementation file. + std::optional<std::vector<std::string>> ImplementationFileExtensions; + /// Output warnings from headers matching this filter. Warnings from /// main files will always be displayed. std::optional<std::string> HeaderFilterRegex; Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -123,6 +123,9 @@ bool Ignored = false; IO.mapOptional("Checks", Options.Checks); IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors); + IO.mapOptional("HeaderFileExtensions", Options.HeaderFileExtensions); + IO.mapOptional("ImplementationFileExtensions", + Options.ImplementationFileExtensions); IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex); IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // legacy compatibility IO.mapOptional("FormatStyle", Options.FormatStyle); @@ -145,6 +148,8 @@ ClangTidyOptions Options; Options.Checks = ""; Options.WarningsAsErrors = ""; + Options.HeaderFileExtensions = {"h", "hh", "hpp", "hxx"}; + Options.ImplementationFileExtensions = {"c", "cc", "cpp", "cxx"}; Options.HeaderFilterRegex = ""; Options.SystemHeaders = false; Options.FormatStyle = "none"; @@ -181,6 +186,9 @@ unsigned Order) { mergeCommaSeparatedLists(Checks, Other.Checks); mergeCommaSeparatedLists(WarningsAsErrors, Other.WarningsAsErrors); + overrideValue(HeaderFileExtensions, Other.HeaderFileExtensions); + overrideValue(ImplementationFileExtensions, + Other.ImplementationFileExtensions); overrideValue(HeaderFilterRegex, Other.HeaderFilterRegex); overrideValue(SystemHeaders, Other.SystemHeaders); overrideValue(FormatStyle, Other.FormatStyle);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits