Author: Matt Beardsley
Date: 2021-10-05T18:09:53+02:00
New Revision: 32ab79ebc496d73cb0eb3ad3b54d32b00fc49ba1

URL: 
https://github.com/llvm/llvm-project/commit/32ab79ebc496d73cb0eb3ad3b54d32b00fc49ba1
DIFF: 
https://github.com/llvm/llvm-project/commit/32ab79ebc496d73cb0eb3ad3b54d32b00fc49ba1.diff

LOG: [clang-tidy] Fix add_new_check.py to generate correct list.rst autofix 
column from relative path

Previously, the code in add_new_check.py that looks for fixit keywords in check 
source files when generating list.rst assumed that the script would only be 
called from its own path. That means it doesn't find any source files for the 
checks it's attempting to scan for, and it defaults to writing out nothing in 
the "Offers fixes" column for all checks. Other parts of add_new_check.py work 
from other paths, just not this part.

After this fix, add_new_check.py's "offers fixes" column generation for 
list.rst will be consistent regardless of what path it's called from by using 
the caller path that's deduced elsewhere already from sys.argv[0].

Reviewed By: kbobyrev

Differential Revision: https://reviews.llvm.org/D110600

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/add_new_check.py

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 0312c04e047c7..a3554b0959759 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -323,13 +323,13 @@ def update_checks_list(clang_tidy_path):
   def has_auto_fix(check_name):
     dirname, _, check_name = check_name.partition("-")
 
-    checkerCode = get_actual_filename(dirname,
-                                      get_camel_name(check_name) + '.cpp')
+    checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
+                                       get_camel_name(check_name) + '.cpp')
 
-    if not os.path.isfile(checkerCode):
+    if not os.path.isfile(checker_code):
       return ""
 
-    with io.open(checkerCode, encoding='utf8') as f:
+    with io.open(checker_code, encoding='utf8') as f:
       code = f.read()
       if 'FixItHint' in code or "ReplacementText" in code or "fixit" in code:
         # Some simple heuristics to figure out if a checker has an autofix or 
not.


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

Reply via email to