Skip to content

Commit c7575fc

Browse files
committed
Revert "[clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions options"
This reverts commit 4240c91. The current solution won't work since getLocalOrGlobal does not support returning a vector. More work needs to be put into ensuring both the local and global way of setting the options are available during the transition period.
1 parent 177a0e5 commit c7575fc

File tree

14 files changed

+23
-161
lines changed

14 files changed

+23
-161
lines changed

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ template <> struct MappingTraits<ClangTidyOptions> {
122122
bool Ignored = false;
123123
IO.mapOptional("Checks", Options.Checks);
124124
IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
125-
IO.mapOptional("HeaderFileExtensions", Options.HeaderFileExtensions);
126-
IO.mapOptional("ImplementationFileExtensions",
127-
Options.ImplementationFileExtensions);
128125
IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
129126
IO.mapOptional("AnalyzeTemporaryDtors", Ignored); // deprecated
130127
IO.mapOptional("FormatStyle", Options.FormatStyle);
@@ -145,8 +142,6 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
145142
ClangTidyOptions Options;
146143
Options.Checks = "";
147144
Options.WarningsAsErrors = "";
148-
Options.HeaderFileExtensions = {"", "h", "hh", "hpp", "hxx"};
149-
Options.ImplementationFileExtensions = {"c", "cc", "cpp", "cxx"};
150145
Options.HeaderFilterRegex = "";
151146
Options.SystemHeaders = false;
152147
Options.FormatStyle = "none";
@@ -183,9 +178,6 @@ ClangTidyOptions &ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
183178
unsigned Order) {
184179
mergeCommaSeparatedLists(Checks, Other.Checks);
185180
mergeCommaSeparatedLists(WarningsAsErrors, Other.WarningsAsErrors);
186-
overrideValue(HeaderFileExtensions, Other.HeaderFileExtensions);
187-
overrideValue(ImplementationFileExtensions,
188-
Other.ImplementationFileExtensions);
189181
overrideValue(HeaderFilterRegex, Other.HeaderFilterRegex);
190182
overrideValue(SystemHeaders, Other.SystemHeaders);
191183
overrideValue(FormatStyle, Other.FormatStyle);

clang-tools-extra/clang-tidy/ClangTidyOptions.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ struct ClangTidyOptions {
7171
/// WarningsAsErrors filter.
7272
std::optional<std::string> WarningsAsErrors;
7373

74-
/// File extensions to consider to determine if a given diagnostic is located
75-
/// in a header file.
76-
std::optional<std::vector<std::string>> HeaderFileExtensions;
77-
78-
/// File extensions to consider to determine if a given diagnostic is located
79-
/// is located in an implementation file.
80-
std::optional<std::vector<std::string>> ImplementationFileExtensions;
81-
8274
/// Output warnings from headers matching this filter. Warnings from
8375
/// main files will always be displayed.
8476
std::optional<std::string> HeaderFilterRegex;

clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ Configuration files:
4646
4747
$ clang-tidy -dump-config
4848
---
49-
Checks: '-*,some-check'
50-
WarningsAsErrors: ''
51-
HeaderFileExtensions: ['', 'h','hh','hpp','hxx']
52-
ImplementationFileExtensions: ['c','cc','cpp','cxx']
53-
HeaderFilterRegex: ''
54-
FormatStyle: none
55-
InheritParentConfig: true
56-
User: user
49+
Checks: '-*,some-check'
50+
WarningsAsErrors: ''
51+
HeaderFilterRegex: ''
52+
FormatStyle: none
53+
InheritParentConfig: true
54+
User: user
5755
CheckOptions:
5856
some-check.SomeOption: 'some value'
5957
...
@@ -132,10 +130,10 @@ well.
132130
cl::init(false), cl::cat(ClangTidyCategory));
133131

134132
static cl::opt<bool> FixNotes("fix-notes", cl::desc(R"(
135-
If a warning has no fix, but a single fix can
136-
be found through an associated diagnostic note,
137-
apply the fix.
138-
Specifying this flag will implicitly enable the
133+
If a warning has no fix, but a single fix can
134+
be found through an associated diagnostic note,
135+
apply the fix.
136+
Specifying this flag will implicitly enable the
139137
'--fix' flag.
140138
)"),
141139
cl::init(false), cl::cat(ClangTidyCategory));
@@ -460,26 +458,6 @@ static bool verifyChecks(const StringSet<> &AllChecks, StringRef CheckGlob,
460458
return AnyInvalid;
461459
}
462460

463-
static bool verifyFileExtensions(
464-
const std::vector<std::string> &HeaderFileExtensions,
465-
const std::vector<std::string> &ImplementationFileExtensions,
466-
StringRef Source) {
467-
bool AnyInvalid = false;
468-
for (const auto &HeaderExtension : HeaderFileExtensions) {
469-
for (const auto &ImplementationExtension : ImplementationFileExtensions) {
470-
if (HeaderExtension == ImplementationExtension) {
471-
AnyInvalid = true;
472-
auto &Output = llvm::WithColor::warning(llvm::errs(), Source)
473-
<< "HeaderFileExtension '" << HeaderExtension << '\''
474-
<< " is the same as ImplementationFileExtension '"
475-
<< ImplementationExtension << '\'';
476-
Output << VerifyConfigWarningEnd;
477-
}
478-
}
479-
}
480-
return AnyInvalid;
481-
}
482-
483461
int clangTidyMain(int argc, const char **argv) {
484462
llvm::InitLLVM X(argc, argv);
485463

@@ -583,11 +561,6 @@ int clangTidyMain(int argc, const char **argv) {
583561
if (Opts.Checks)
584562
AnyInvalid |= verifyChecks(Valid.Names, *Opts.Checks, Source);
585563

586-
if (Opts.HeaderFileExtensions && Opts.ImplementationFileExtensions)
587-
AnyInvalid |=
588-
verifyFileExtensions(*Opts.HeaderFileExtensions,
589-
*Opts.ImplementationFileExtensions, Source);
590-
591564
for (auto Key : Opts.CheckOptions.keys()) {
592565
if (Valid.Options.contains(Key))
593566
continue;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ Improvements to clang-tidy
106106
which is no longer in use. The option will be fully removed in
107107
:program:`clang-tidy` version 18.
108108

109-
- New global configuration file options `HeaderFileExtensions` and
110-
`ImplementationFileExtensions`, replacing the check-local options of the
111-
same name.
112-
113109
New checks
114110
^^^^^^^^^^
115111

@@ -161,61 +157,26 @@ Changes in existing checks
161157
<clang-tidy/checks/bugprone/assignment-in-if-condition>` check when there
162158
was an assignement in a lambda found in the condition of an ``if``.
163159

164-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
165-
in :doc:`bugprone-dynamic-static-initializers
166-
<clang-tidy/checks/bugprone/dynamic-static-initializers>` check.
167-
Global options of the same name should be used instead.
168-
169160
- Improved :doc:`bugprone-signal-handler
170161
<clang-tidy/checks/bugprone/signal-handler>` check. Partial
171162
support for C++14 signal handler rules was added. Bug report generation was
172163
improved.
173164

174-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
175-
in :doc:`bugprone-suspicious-include
176-
<clang-tidy/checks/bugprone/suspicious-include>` check.
177-
Global options of the same name should be used instead.
178-
179165
- Fixed a false positive in :doc:`cppcoreguidelines-pro-type-member-init
180166
<clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` when warnings
181167
would be emitted for uninitialized members of an anonymous union despite
182168
there being an initializer for one of the other members.
183169

184-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
185-
in :doc:`google-build-namespaces
186-
<clang-tidy/checks/google/build-namespaces>` check.
187-
Global options of the same name should be used instead.
188-
189-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
190-
in :doc:`google-global-names-in-headers
191-
<clang-tidy/checks/google/global-names-in-headers>` check.
192-
Global options of the same name should be used instead.
193-
194170
- Fixed false positives in :doc:`google-objc-avoid-throwing-exception
195171
<clang-tidy/checks/google/objc-avoid-throwing-exception>` check for exceptions
196172
thrown by code emitted from macros in system headers.
197173

198-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
199-
in :doc:`llvm-header-guard
200-
<clang-tidy/checks/llvm/header-guard>` check.
201-
Global options of the same name should be used instead.
202-
203-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
204-
in :doc:`misc-definitions-in-headers
205-
<clang-tidy/checks/misc/definitions-in-headers>` check.
206-
Global options of the same name should be used instead.
207-
208174
- Improved :doc:`misc-redundant-expression <clang-tidy/checks/misc/redundant-expression>`
209175
check.
210176

211177
The check now skips concept definitions since redundant expressions still make sense
212178
inside them.
213179

214-
- Deprecated check-local options `HeaderFileExtensions` and `ImplementationFileExtensions`
215-
in :doc:`misc-unused-using-decls
216-
<clang-tidy/checks/misc/unused-using-decls>` check.
217-
Global options of the same name should be used instead.
218-
219180
- Improved :doc:`modernize-loop-convert <clang-tidy/checks/modernize/loop-convert>`
220181
to check for container functions ``begin``/``end`` etc on base classes of the container
221182
type, instead of only as direct members of the container type itself.

clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ Options
1919
-------
2020
.. option:: HeaderFileExtensions
2121

22-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
23-
version 18. Please use the global configuration option
24-
`HeaderFileExtensions`.
25-
2622
Default value: ``";h;hh;hpp;hxx"``
2723
A semicolon-separated list of filename extensions of header files (the
2824
filename extensions should not contain a "." prefix). For extension-less
@@ -31,10 +27,6 @@ Options
3127

3228
.. option:: ImplementationFileExtensions
3329

34-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`.
35-
version 18. Please use the global configuration option
36-
`ImplementationFileExtensions`.
37-
3830
Default value: ``"c;cc;cpp;cxx"``
3931
Likewise, a semicolon-separated list of filename extensions of
4032
implementation files.

clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ Options
1717

1818
.. option:: HeaderFileExtensions
1919

20-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
21-
version 18. Please use the global configuration option
22-
`HeaderFileExtensions`.
23-
2420
A comma-separated list of filename extensions of header files (the filename
2521
extensions should not include "." prefix). Default is "h,hh,hpp,hxx".
2622
For header files without an extension, use an empty string (if there are no

clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ Options
1414

1515
.. option:: HeaderFileExtensions
1616

17-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
18-
version 18. Please use the global configuration option
19-
`HeaderFileExtensions`.
20-
2117
A comma-separated list of filename extensions of header files (the filename
2218
extensions should not contain "." prefix). Default is "h".
2319
For header files without an extension, use an empty string (if there are no

clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ Options
1010

1111
.. option:: HeaderFileExtensions
1212

13-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
14-
version 18. Please use the global configuration option
15-
`HeaderFileExtensions`.
16-
1713
A comma-separated list of filename extensions of header files (the filename
1814
extensions should not include "." prefix). Default is "h,hh,hpp,hxx".
1915
For header files without an extension, use an empty string (if there are no

clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ Options
9292

9393
.. option:: HeaderFileExtensions
9494

95-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
96-
version 18. Please use the global configuration option
97-
`HeaderFileExtensions`.
98-
9995
A comma-separated list of filename extensions of header files (the filename
10096
extensions should not include "." prefix). Default is "h,hh,hpp,hxx".
10197
For header files without an extension, use an empty string (if there are no
@@ -104,9 +100,5 @@ Options
104100

105101
.. option:: UseHeaderFileExtension
106102

107-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
108-
version 18. The check will unconditionally use the global option
109-
`HeaderFileExtensions`.
110-
111103
When `true`, the check will use the file extension to distinguish header
112104
files. Default is `true`.

clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ Options
2222

2323
.. option:: HeaderFileExtensions
2424

25-
Note: this option is deprecated, it will be removed in :program:`clang-tidy`
26-
version 18. Please use the global configuration option
27-
`HeaderFileExtensions`.
28-
2925
A semicolon-separated list of filename extensions of header files (the filename
3026
extensions should not include "." prefix). Default is "h,hh,hpp,hxx".
3127
For extension-less header files, use an empty string or leave an

0 commit comments

Comments
 (0)