Skip to content

Commit f5f9bf4

Browse files
committed
Add documentation redirects for clang-tidy checkers that are exposed under multiple checker names. Updates the Python script for adding checks to properly handle these aliases.
llvm-svn: 257347
1 parent a0e5cd5 commit f5f9bf4

14 files changed

+90
-7
lines changed

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

+17-7
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,25 @@ def write_test(module_path, module, check_name):
215215

216216
# Recreates the list of checks in the docs/clang-tidy/checks directory.
217217
def update_checks_list(module_path):
218-
filename = os.path.normpath(
219-
os.path.join(module_path, '../../docs/clang-tidy/checks/list.rst'))
218+
docs_dir = os.path.join(module_path, '../../docs/clang-tidy/checks')
219+
filename = os.path.normpath(os.path.join(docs_dir, 'list.rst'))
220220
with open(filename, 'r') as f:
221221
lines = f.readlines()
222-
223-
checks = map(lambda s: ' ' + s.replace('.rst', '\n'),
224-
filter(lambda s: s.endswith('.rst') and s != 'list.rst',
225-
os.listdir(os.path.join(module_path, '../../docs/clang-tidy/checks'))))
226-
checks.sort()
222+
doc_files = filter(
223+
lambda s: s.endswith('.rst') and s != 'list.rst',
224+
os.listdir(docs_dir))
225+
doc_files.sort()
226+
227+
def format_link(doc_file):
228+
check_name = doc_file.replace('.rst', '')
229+
with open(os.path.join(docs_dir, doc_file), 'r') as doc:
230+
match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*', doc.read())
231+
if match:
232+
return ' %(check)s (redirects to %(target)s) <%(check)s>\n' % {
233+
'check' : check_name, 'target' : match.group(1) }
234+
return ' %s\n' % check_name
235+
236+
checks = map(format_link, doc_files)
227237

228238
print('Updating %s...' % filename)
229239
with open(filename, 'wb') as f:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. title:: clang-tidy - cert-dcl03-c
2+
.. meta::
3+
:http-equiv=refresh: 5;URL=misc-static-assert.html
4+
5+
cert-dcl03-c
6+
============
7+
8+
The cert-dcl03-c checker is an alias, please see
9+
`misc-static-assert <misc-static-assert.html>`_ for more information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. title:: clang-tidy - cert-dcl54-cpp
2+
.. meta::
3+
:http-equiv=refresh: 5;URL=misc-new-delete-overloads.html
4+
5+
cert-dcl54-cpp
6+
==============
7+
8+
The cert-dcl54-cpp checker is an alias, please see
9+
`misc-new-delete-overloads <misc-new-delete-overloads.html>`_ for more
10+
information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. title:: clang-tidy - cert-dcl59-cpp
2+
.. meta::
3+
:http-equiv=refresh: 5;URL=google-build-namespaces.html
4+
5+
cert-dcl59-cpp
6+
==============
7+
8+
The cert-dcl59-cpp checker is an alias, please see
9+
`google-build-namespaces <google-build-namespaces.html>`_ for more information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. title:: clang-tidy - cert-err61-cpp
2+
.. meta::
3+
:http-equiv=refresh: 5;URL=misc-throw-by-value-catch-by-reference.html
4+
5+
cert-err61-cpp
6+
==============
7+
8+
The cert-err61-cpp checker is an alias, please see
9+
`misc-throw-by-value-catch-by-reference <misc-throw-by-value-catch-by-reference.html>`_
10+
for more information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. title:: clang-tidy - cert-fio38-c
2+
.. meta::
3+
:http-equiv=refresh: 5;URL=misc-non-copyable-objects.html
4+
5+
cert-fio38-c
6+
============
7+
8+
The cert-fio38-c checker is an alias, please see
9+
`misc-non-copyable-objects <misc-non-copyable-objects.html>`_ for more
10+
information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. title:: clang-tidy - cert-oop11-cpp
2+
.. meta::
3+
:http-equiv=refresh: 5;URL=misc-move-constructor-init.html
4+
5+
cert-oop11-cpp
6+
==============
7+
8+
The cert-oop11-cpp checker is an alias, please see
9+
`misc-move-constructor-init <misc-move-constructor-init.html>`_ for more
10+
information.

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

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
google-build-namespaces
44
=======================
55

6+
"cert-dcl59-cpp" redirects here as an alias for this checker.
67

78
Finds anonymous namespaces in headers.
89

clang-tools-extra/docs/clang-tidy/checks/list.rst

+6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ Clang-Tidy Checks
44
=========================
55

66
.. toctree::
7+
cert-dcl03-c (redirects to misc-static-assert) <cert-dcl03-c>
78
cert-dcl50-cpp
9+
cert-dcl54-cpp (redirects to misc-new-delete-overloads) <cert-dcl54-cpp>
10+
cert-dcl59-cpp (redirects to google-build-namespaces) <cert-dcl59-cpp>
811
cert-err52-cpp
912
cert-err58-cpp
1013
cert-err60-cpp
14+
cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) <cert-err61-cpp>
15+
cert-fio38-c (redirects to misc-non-copyable-objects) <cert-fio38-c>
16+
cert-oop11-cpp (redirects to misc-move-constructor-init) <cert-oop11-cpp>
1117
cppcoreguidelines-pro-bounds-array-to-pointer-decay
1218
cppcoreguidelines-pro-bounds-constant-array-index
1319
cppcoreguidelines-pro-bounds-pointer-arithmetic

clang-tools-extra/docs/clang-tidy/checks/misc-move-constructor-init.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
misc-move-constructor-init
44
==========================
55

6+
"cert-oop11-cpp" redirects here as an alias for this checker.
67

78
The check flags user-defined move constructors that have a ctor-initializer
89
initializing a member or base class through a copy constructor instead of a

clang-tools-extra/docs/clang-tidy/checks/misc-new-delete-overloads.rst

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
misc-new-delete-overloads
44
=========================
55

6+
"cert-dcl54-cpp" redirects here as an alias for this checker.
7+
68
The check flags overloaded operator new() and operator delete() functions that
79
do not have a corresponding free store function defined within the same scope.
810
For instance, the check will flag a class implementation of a non-placement

clang-tools-extra/docs/clang-tidy/checks/misc-non-copyable-objects.rst

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
misc-non-copyable-objects
44
=========================
55

6+
"cert-fio38-c" redirects here as an alias for this checker.
7+
68
The check flags dereferences and non-pointer declarations of objects that are
79
not meant to be passed by value, such as C FILE objects or POSIX
810
pthread_mutex_t objects.

clang-tools-extra/docs/clang-tidy/checks/misc-static-assert.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
misc-static-assert
44
==================
55

6+
"cert-dcl03-c" redirects here as an alias for this checker.
67

78
Replaces ``assert()`` with ``static_assert()`` if the condition is evaluatable
89
at compile time.

clang-tools-extra/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
misc-throw-by-value-catch-by-reference
44
======================================
55

6+
"cert-err61-cpp" redirects here as an alias for this checker.
7+
68
Finds violations of the rule "Throw by value, catch by reference" presented for example in "C++ Coding Standards" by H. Sutter and A. Alexandrescu. This check also has the option to find violations of the rule "Throw anonymous temporaries" (https://www.securecoding.cert.org/confluence/display/cplusplus/ERR09-CPP.+Throw+anonymous+temporaries). The option is named "CheckThrowTemporaries" and it's on by default.
79

810
Exceptions:

0 commit comments

Comments
 (0)