Skip to content

Commit 3b6d879

Browse files
carlosgalvezpCarlos Gálvez
andauthored
[clang-tidy][doc] Improve documentation of the -line-filter flag (#153372)
Fixes #25589 Co-authored-by: Carlos Gálvez <[email protected]>
1 parent c164e63 commit 3b6d879

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,19 @@ in .clang-tidy file, if any.
162162
cl::init(false), cl::cat(ClangTidyCategory));
163163

164164
static cl::opt<std::string> LineFilter("line-filter", desc(R"(
165-
List of files with line ranges to filter the
166-
warnings. Can be used together with
167-
-header-filter. The format of the list is a
168-
JSON array of objects:
165+
List of files and line ranges to output diagnostics from.
166+
The range is inclusive on both ends. Can be used together
167+
with -header-filter. The format of the list is a JSON
168+
array of objects. For example:
169+
169170
[
170171
{"name":"file1.cpp","lines":[[1,3],[5,7]]},
171172
{"name":"file2.h"}
172173
]
174+
175+
This will output diagnostics from 'file1.cpp' only for
176+
the line ranges [1,3] and [5,7], as well as all from the
177+
entire 'file2.h'.
173178
)"),
174179
cl::init(""),
175180
cl::cat(ClangTidyCategory));

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ async def main() -> None:
483483
parser.add_argument(
484484
"-line-filter",
485485
default=None,
486-
help="List of files with line ranges to filter the warnings.",
486+
help="List of files and line ranges to output diagnostics from.",
487487
)
488488
if yaml:
489489
parser.add_argument(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ Improvements to clang-tidy
109109
`enable-check-profile` to enable per-check timing profiles and print a
110110
report based on all analyzed files.
111111

112+
- Improved documentation of the `-line-filter` command-line flag of
113+
:program:`clang-tidy` and :program:`run-clang-tidy.py`.
114+
112115
New checks
113116
^^^^^^^^^^
114117

clang-tools-extra/docs/clang-tidy/index.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,19 @@ An overview of all the command-line options:
213213
Can be used together with -line-filter.
214214
This option overrides the 'HeaderFilterRegex'
215215
option in .clang-tidy file, if any.
216-
--line-filter=<string> - List of files with line ranges to filter the
217-
warnings. Can be used together with
218-
-header-filter. The format of the list is a
219-
JSON array of objects:
216+
--line-filter=<string> - List of files and line ranges to output diagnostics from.
217+
The range is inclusive on both ends. Can be used together
218+
with -header-filter. The format of the list is a JSON
219+
array of objects. For example:
220+
220221
[
221222
{"name":"file1.cpp","lines":[[1,3],[5,7]]},
222223
{"name":"file2.h"}
223224
]
225+
226+
This will output diagnostics from 'file1.cpp' only for
227+
the line ranges [1,3] and [5,7], as well as all from the
228+
entire 'file2.h'.
224229
--list-checks - List all enabled checks and exit. Use with
225230
-checks=* to list all available checks.
226231
--load=<pluginfilename> - Load the specified plugin

0 commit comments

Comments
 (0)