Author: Carlos Galvez
Date: 2025-08-14T07:55:20+02:00
New Revision: 3b6d8798ba0752b78d6c3d1ae13e08fb40a5e4dc

URL: 
https://github.com/llvm/llvm-project/commit/3b6d8798ba0752b78d6c3d1ae13e08fb40a5e4dc
DIFF: 
https://github.com/llvm/llvm-project/commit/3b6d8798ba0752b78d6c3d1ae13e08fb40a5e4dc.diff

LOG: [clang-tidy][doc] Improve documentation of the -line-filter flag (#153372)

Fixes #25589

Co-authored-by: Carlos Gálvez <carlos.gal...@zenseact.com>

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
    clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/docs/clang-tidy/index.rst

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 97dfd0fc943b4..df3a8b22b1e24 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -162,14 +162,19 @@ in .clang-tidy file, if any.
                                    cl::init(false), 
cl::cat(ClangTidyCategory));
 
 static cl::opt<std::string> LineFilter("line-filter", desc(R"(
-List of files with line ranges to filter the
-warnings. Can be used together with
--header-filter. The format of the list is a
-JSON array of objects:
+List of files and line ranges to output diagnostics from.
+The range is inclusive on both ends. Can be used together
+with -header-filter. The format of the list is a JSON
+array of objects. For example:
+
   [
     {"name":"file1.cpp","lines":[[1,3],[5,7]]},
     {"name":"file2.h"}
   ]
+
+This will output diagnostics from 'file1.cpp' only for
+the line ranges [1,3] and [5,7], as well as all from the
+entire 'file2.h'.
 )"),
                                        cl::init(""),
                                        cl::cat(ClangTidyCategory));

diff  --git a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py 
b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
index 80f1766b0bf10..670e0a2c7678a 100755
--- a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ b/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -483,7 +483,7 @@ async def main() -> None:
     parser.add_argument(
         "-line-filter",
         default=None,
-        help="List of files with line ranges to filter the warnings.",
+        help="List of files and line ranges to output diagnostics from.",
     )
     if yaml:
         parser.add_argument(

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 187aae2ec8c90..b481c56c262c4 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -109,6 +109,9 @@ Improvements to clang-tidy
   `enable-check-profile` to enable per-check timing profiles and print a
   report based on all analyzed files.
 
+- Improved documentation of the `-line-filter` command-line flag of
+  :program:`clang-tidy` and :program:`run-clang-tidy.py`.
+
 New checks
 ^^^^^^^^^^
 

diff  --git a/clang-tools-extra/docs/clang-tidy/index.rst 
b/clang-tools-extra/docs/clang-tidy/index.rst
index b7a366e874130..e8ce903fcb076 100644
--- a/clang-tools-extra/docs/clang-tidy/index.rst
+++ b/clang-tools-extra/docs/clang-tidy/index.rst
@@ -213,14 +213,19 @@ An overview of all the command-line options:
                                        Can be used together with -line-filter.
                                        This option overrides the 
'HeaderFilterRegex'
                                        option in .clang-tidy file, if any.
-    --line-filter=<string>           - List of files with line ranges to 
filter the
-                                       warnings. Can be used together with
-                                       -header-filter. The format of the list 
is a
-                                       JSON array of objects:
+    --line-filter=<string>           - List of files and line ranges to output 
diagnostics from.
+                                       The range is inclusive on both ends. 
Can be used together
+                                       with -header-filter. The format of the 
list is a JSON
+                                       array of objects. For example:
+
                                          [
                                            
{"name":"file1.cpp","lines":[[1,3],[5,7]]},
                                            {"name":"file2.h"}
                                          ]
+
+                                       This will output diagnostics from 
'file1.cpp' only for
+                                       the line ranges [1,3] and [5,7], as 
well as all from the
+                                       entire 'file2.h'.
     --list-checks                    - List all enabled checks and exit. Use 
with
                                        -checks=* to list all available checks.
     --load=<pluginfilename>          - Load the specified plugin


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to