[clang-tools-extra] d7b6574 - [clang-tidy] Recognize transformer checks as providing fixits
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 5 15:15:23 PST 2022
Author: Richard
Date: 2022-01-05T16:13:52-07:00
New Revision: d7b6574c3bf671d70acd751a8c85d3a062dcc7c6
URL: https://github.com/llvm/llvm-project/commit/d7b6574c3bf671d70acd751a8c85d3a062dcc7c6
DIFF: https://github.com/llvm/llvm-project/commit/d7b6574c3bf671d70acd751a8c85d3a062dcc7c6.diff
LOG: [clang-tidy] Recognize transformer checks as providing fixits
- Recognize older checks that might not end with Check.cpp
- Update list of checks based on improvements to add_new_check
- Fix spelling error in TransformerClangTidyCheck.h
Fixes #52962
Differential Revision: https://reviews.llvm.org/D116550
Added:
Modified:
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
clang-tools-extra/docs/clang-tidy/checks/list.rst
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py
index a3554b0959759..1e26b07121c61 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -324,16 +324,20 @@ def has_auto_fix(check_name):
dirname, _, check_name = check_name.partition("-")
checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
- get_camel_name(check_name) + '.cpp')
-
+ get_camel_check_name(check_name) + '.cpp')
if not os.path.isfile(checker_code):
- return ""
+ # Some older checks don't end with 'Check.cpp'
+ checker_code = get_actual_filename(os.path.join(clang_tidy_path, dirname),
+ get_camel_name(check_name) + '.cpp')
+ if not os.path.isfile(checker_code):
+ return ''
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.
- return ' "Yes"'
+ for needle in ['FixItHint', 'ReplacementText', 'fixit', 'TransformerClangTidyCheck']:
+ if needle in code:
+ # Some simple heuristics to figure out if a checker has an autofix or not.
+ return ' "Yes"'
return ""
def process_doc(doc_file):
@@ -416,7 +420,11 @@ def write_docs(module_path, module, check_name):
def get_camel_name(check_name):
return ''.join(map(lambda elem: elem.capitalize(),
- check_name.split('-'))) + 'Check'
+ check_name.split('-')))
+
+
+def get_camel_check_name(check_name):
+ return get_camel_name(check_name) + 'Check'
def main():
@@ -458,7 +466,7 @@ def main():
module = args.module
check_name = args.check
- check_name_camel = get_camel_name(check_name)
+ check_name_camel = get_camel_check_name(check_name)
if check_name.startswith(module):
print('Check name "%s" must not start with the module "%s". Exiting.' % (
check_name, module))
diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
index 9736e64e7c311..d26737935b1aa 100644
--- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -54,7 +54,7 @@ class TransformerClangTidyCheck : public ClangTidyCheck {
StringRef Name, ClangTidyContext *Context);
/// Convenience overload of the constructor when the rule doesn't have any
- /// dependies.
+ /// dependencies.
TransformerClangTidyCheck(transformer::RewriteRule R, StringRef Name,
ClangTidyContext *Context);
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 1e6936f9cbdf9..8d0a568cff881 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -116,13 +116,12 @@ Clang-Tidy Checks
`cert-dcl50-cpp <cert-dcl50-cpp.html>`_,
`cert-dcl58-cpp <cert-dcl58-cpp.html>`_,
`cert-env33-c <cert-env33-c.html>`_,
+ `cert-err33-c <cert-err33-c.html>`_,
`cert-err34-c <cert-err34-c.html>`_,
`cert-err52-cpp <cert-err52-cpp.html>`_,
`cert-err58-cpp <cert-err58-cpp.html>`_,
`cert-err60-cpp <cert-err60-cpp.html>`_,
- `cert-exp42-c <cert-exp42-c.html>`_,
`cert-flp30-c <cert-flp30-c.html>`_,
- `cert-flp37-c <cert-flp37-c.html>`_,
`cert-mem57-cpp <cert-mem57-cpp.html>`_,
`cert-msc50-cpp <cert-msc50-cpp.html>`_,
`cert-msc51-cpp <cert-msc51-cpp.html>`_,
@@ -213,7 +212,7 @@ Clang-Tidy Checks
`llvmlibc-implementation-in-namespace <llvmlibc-implementation-in-namespace.html>`_,
`llvmlibc-restrict-system-libc-headers <llvmlibc-restrict-system-libc-headers.html>`_, "Yes"
`misc-definitions-in-headers <misc-definitions-in-headers.html>`_, "Yes"
- `misc-misleading-identifier <misc-mileading-identifier.html>`_,
+ `misc-misleading-identifier <misc-misleading-identifier.html>`_,
`misc-misplaced-const <misc-misplaced-const.html>`_,
`misc-new-delete-overloads <misc-new-delete-overloads.html>`_,
`misc-no-recursion <misc-no-recursion.html>`_,
@@ -260,8 +259,8 @@ Clang-Tidy Checks
`modernize-use-using <modernize-use-using.html>`_, "Yes"
`mpi-buffer-deref <mpi-buffer-deref.html>`_, "Yes"
`mpi-type-mismatch <mpi-type-mismatch.html>`_, "Yes"
- `objc-avoid-nserror-init <objc-avoid-nserror-init.html>`_,
`objc-assert-equals <objc-assert-equals.html>`_, "Yes"
+ `objc-avoid-nserror-init <objc-avoid-nserror-init.html>`_,
`objc-dealloc-in-category <objc-dealloc-in-category.html>`_,
`objc-forbidden-subclassing <objc-forbidden-subclassing.html>`_,
`objc-missing-hash <objc-missing-hash.html>`_,
@@ -283,16 +282,16 @@ Clang-Tidy Checks
`performance-noexcept-move-constructor <performance-noexcept-move-constructor.html>`_, "Yes"
`performance-trivially-destructible <performance-trivially-destructible.html>`_, "Yes"
`performance-type-promotion-in-math-fn <performance-type-promotion-in-math-fn.html>`_, "Yes"
- `performance-unnecessary-copy-initialization <performance-unnecessary-copy-initialization.html>`_,
+ `performance-unnecessary-copy-initialization <performance-unnecessary-copy-initialization.html>`_, "Yes"
`performance-unnecessary-value-param <performance-unnecessary-value-param.html>`_, "Yes"
`portability-restrict-system-includes <portability-restrict-system-includes.html>`_, "Yes"
`portability-simd-intrinsics <portability-simd-intrinsics.html>`_,
- `readability-avoid-const-params-in-decls <readability-avoid-const-params-in-decls.html>`_,
+ `readability-avoid-const-params-in-decls <readability-avoid-const-params-in-decls.html>`_, "Yes"
`readability-braces-around-statements <readability-braces-around-statements.html>`_, "Yes"
`readability-const-return-type <readability-const-return-type.html>`_, "Yes"
`readability-container-data-pointer <readability-container-data-pointer.html>`_, "Yes"
`readability-container-size-empty <readability-container-size-empty.html>`_, "Yes"
- `readability-convert-member-functions-to-static <readability-convert-member-functions-to-static.html>`_,
+ `readability-convert-member-functions-to-static <readability-convert-member-functions-to-static.html>`_, "Yes"
`readability-delete-null-pointer <readability-delete-null-pointer.html>`_, "Yes"
`readability-else-after-return <readability-else-after-return.html>`_, "Yes"
`readability-function-cognitive-complexity <readability-function-cognitive-complexity.html>`_,
@@ -338,13 +337,14 @@ Clang-Tidy Checks
`cert-dcl03-c <cert-dcl03-c.html>`_, `misc-static-assert <misc-static-assert.html>`_, "Yes"
`cert-dcl16-c <cert-dcl16-c.html>`_, `readability-uppercase-literal-suffix <readability-uppercase-literal-suffix.html>`_, "Yes"
`cert-dcl37-c <cert-dcl37-c.html>`_, `bugprone-reserved-identifier <bugprone-reserved-identifier.html>`_, "Yes"
- `cert-err33-c <cert-err33-c.html>`_, `bugprone-unused-return-value <bugprone-unused-return-value.html>`_,
`cert-dcl51-cpp <cert-dcl51-cpp.html>`_, `bugprone-reserved-identifier <bugprone-reserved-identifier.html>`_, "Yes"
`cert-dcl54-cpp <cert-dcl54-cpp.html>`_, `misc-new-delete-overloads <misc-new-delete-overloads.html>`_,
`cert-dcl59-cpp <cert-dcl59-cpp.html>`_, `google-build-namespaces <google-build-namespaces.html>`_,
`cert-err09-cpp <cert-err09-cpp.html>`_, `misc-throw-by-value-catch-by-reference <misc-throw-by-value-catch-by-reference.html>`_,
`cert-err61-cpp <cert-err61-cpp.html>`_, `misc-throw-by-value-catch-by-reference <misc-throw-by-value-catch-by-reference.html>`_,
+ `cert-exp42-c <cert-exp42-c.html>`_, `bugprone-suspicious-memory-comparison <bugprone-suspicious-memory-comparison.html>`_,
`cert-fio38-c <cert-fio38-c.html>`_, `misc-non-copyable-objects <misc-non-copyable-objects.html>`_,
+ `cert-flp37-c <cert-flp37-c.html>`_, `bugprone-suspicious-memory-comparison <bugprone-suspicious-memory-comparison.html>`_,
`cert-msc30-c <cert-msc30-c.html>`_, `cert-msc50-cpp <cert-msc50-cpp.html>`_,
`cert-msc32-c <cert-msc32-c.html>`_, `cert-msc51-cpp <cert-msc51-cpp.html>`_,
`cert-oop11-cpp <cert-oop11-cpp.html>`_, `performance-move-constructor-init <performance-move-constructor-init.html>`_,
More information about the cfe-commits
mailing list