2020-04-08 00:26:40 +08:00
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
FrontendOpenMP
|
|
|
|
Support
|
|
|
|
)
|
2014-09-22 18:41:39 +08:00
|
|
|
|
2014-10-26 09:41:14 +08:00
|
|
|
add_clang_library(clangTidyReadabilityModule
|
2016-03-30 19:31:33 +08:00
|
|
|
AvoidConstParamsInDecls.cpp
|
2014-10-15 18:51:57 +08:00
|
|
|
BracesAroundStatementsCheck.cpp
|
2018-11-01 03:11:38 +08:00
|
|
|
ConstReturnTypeCheck.cpp
|
2021-10-28 02:49:00 +08:00
|
|
|
ContainerContainsCheck.cpp
|
2021-09-16 04:07:51 +08:00
|
|
|
ContainerDataPointerCheck.cpp
|
2015-03-09 20:18:39 +08:00
|
|
|
ContainerSizeEmptyCheck.cpp
|
2019-07-17 05:19:00 +08:00
|
|
|
ConvertMemberFunctionsToStatic.cpp
|
2016-12-31 20:45:59 +08:00
|
|
|
DeleteNullPointerCheck.cpp
|
2022-01-02 13:47:22 +08:00
|
|
|
DuplicateIncludeCheck.cpp
|
2015-01-15 03:37:54 +08:00
|
|
|
ElseAfterReturnCheck.cpp
|
[clang-tidy] Implement readability-function-cognitive-complexity check
Currently, there is basically just one clang-tidy check to impose
some sanity limits on functions - `clang-tidy-readability-function-size`.
It is nice, allows to limit line count, total number of statements,
number of branches, number of function parameters (not counting
implicit `this`), nesting level.
However, those are simple generic metrics. It is still trivially possible
to write a function, which does not violate any of these metrics,
yet is still rather unreadable.
Thus, some additional, slightly more complicated metric is needed.
There is a well-known [[ https://en.wikipedia.org/wiki/Cyclomatic_complexity | Cyclomatic complexity]], but certainly has its downsides.
And there is a [[ https://www.sonarsource.com/docs/CognitiveComplexity.pdf | COGNITIVE COMPLEXITY by SonarSource ]], which is available for opensource on https://sonarcloud.io/.
This check checks function Cognitive Complexity metric, and flags
the functions with Cognitive Complexity exceeding the configured limit.
The default limit is `25`, same as in 'upstream'.
The metric is implemented as per [[ https://www.sonarsource.com/docs/CognitiveComplexity.pdf | COGNITIVE COMPLEXITY by SonarSource ]] specification version 1.2 (19 April 2017), with two notable exceptions:
* `preprocessor conditionals` (`#ifdef`, `#if`, `#elif`, `#else`,
`#endif`) are not accounted for.
Could be done. Currently, upstream does not account for them either.
* `each method in a recursion cycle` is not accounted for.
It can't be fully implemented, because cross-translational-unit
analysis would be needed, which is not possible in clang-tidy.
Thus, at least right now, i completely avoided implementing it.
There are some further possible improvements:
* Are GNU statement expressions (`BinaryConditionalOperator`) really free?
They should probably cause nesting level increase,
and complexity level increase when they are nested within eachother.
* Microsoft SEH support
* ???
Reviewed By: aaron.ballman, JonasToth, lattner
Differential Revision: https://reviews.llvm.org/D36836
2017-08-17 23:57:00 +08:00
|
|
|
FunctionCognitiveComplexityCheck.cpp
|
2015-03-09 20:18:39 +08:00
|
|
|
FunctionSizeCheck.cpp
|
2021-08-12 23:31:26 +08:00
|
|
|
IdentifierLengthCheck.cpp
|
2015-08-19 19:15:36 +08:00
|
|
|
IdentifierNamingCheck.cpp
|
2017-08-08 22:53:52 +08:00
|
|
|
ImplicitBoolConversionCheck.cpp
|
2015-09-10 18:07:11 +08:00
|
|
|
InconsistentDeclarationParameterNameCheck.cpp
|
[clang-tidy] new check 'readability-isolate-declaration'
Summary:
This patch introduces a new clang-tidy check that matches on all `declStmt` that declare more then one variable
and transform them into one statement per declaration if possible.
It currently only focusses on variable declarations but should be extended to cover more kinds of declarations in the future.
It is related to https://reviews.llvm.org/D27621 and does use it's extensive test-suite. Thank you to firolino for his work!
Reviewers: rsmith, aaron.ballman, alexfh, hokein, kbobyrev
Reviewed By: aaron.ballman
Subscribers: ZaMaZaN4iK, mgehre, nemanjai, kbarton, lebedev.ri, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D51949
llvm-svn: 345735
2018-11-01 00:50:44 +08:00
|
|
|
IsolateDeclarationCheck.cpp
|
2018-08-12 22:35:13 +08:00
|
|
|
MagicNumbersCheck.cpp
|
2019-09-23 05:19:41 +08:00
|
|
|
MakeMemberFunctionConstCheck.cpp
|
2017-02-14 18:03:27 +08:00
|
|
|
MisleadingIndentationCheck.cpp
|
2016-09-12 20:04:13 +08:00
|
|
|
MisplacedArrayIndexCheck.cpp
|
2015-03-17 06:31:16 +08:00
|
|
|
NamedParameterCheck.cpp
|
2014-09-22 18:41:39 +08:00
|
|
|
NamespaceCommentCheck.cpp
|
2016-08-23 18:09:08 +08:00
|
|
|
NonConstParameterCheck.cpp
|
2020-01-15 03:05:45 +08:00
|
|
|
QualifiedAutoCheck.cpp
|
2014-10-26 09:41:14 +08:00
|
|
|
ReadabilityTidyModule.cpp
|
2019-10-31 01:26:41 +08:00
|
|
|
RedundantAccessSpecifiersCheck.cpp
|
2016-02-01 23:31:15 +08:00
|
|
|
RedundantControlFlowCheck.cpp
|
2016-11-01 21:26:15 +08:00
|
|
|
RedundantDeclarationCheck.cpp
|
2016-12-13 16:04:11 +08:00
|
|
|
RedundantFunctionPtrDereferenceCheck.cpp
|
2016-10-21 00:08:03 +08:00
|
|
|
RedundantMemberInitCheck.cpp
|
2019-01-11 15:59:47 +08:00
|
|
|
RedundantPreprocessorCheck.cpp
|
2015-03-09 20:18:39 +08:00
|
|
|
RedundantSmartptrGetCheck.cpp
|
2018-09-20 08:02:55 +08:00
|
|
|
RedundantStringCStrCheck.cpp
|
2016-02-26 07:57:23 +08:00
|
|
|
RedundantStringInitCheck.cpp
|
2015-04-11 03:26:43 +08:00
|
|
|
SimplifyBooleanExprCheck.cpp
|
2018-05-17 04:12:06 +08:00
|
|
|
SimplifySubscriptExprCheck.cpp
|
2017-08-08 23:33:48 +08:00
|
|
|
StaticAccessedThroughInstanceCheck.cpp
|
2016-04-05 19:42:08 +08:00
|
|
|
StaticDefinitionInAnonymousNamespaceCheck.cpp
|
2018-01-30 22:55:50 +08:00
|
|
|
StringCompareCheck.cpp
|
2017-09-05 18:58:20 +08:00
|
|
|
SuspiciousCallArgumentCheck.cpp
|
2015-10-20 05:49:51 +08:00
|
|
|
UniqueptrDeleteReleaseCheck.cpp
|
[clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)
Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.
All valid combinations of suffixes are supported.
```
auto x = 1; // OK, no suffix.
auto x = 1u; // warning: integer literal suffix 'u' is not upper-case
auto x = 1U; // OK, suffix is uppercase.
...
```
This is a re-commit, the original was reverted by me in
rL345305 due to discovered bugs. (implicit code, template instantiation)
Tests were added, and the bugs were fixed.
I'm unable to find any further bugs, hopefully there aren't any..
References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun
Reviewed By: aaron.ballman
Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D52670
llvm-svn: 345381
2018-10-26 21:09:27 +08:00
|
|
|
UppercaseLiteralSuffixCheck.cpp
|
2019-10-03 06:39:46 +08:00
|
|
|
UseAnyOfAllOfCheck.cpp
|
2014-09-22 18:41:39 +08:00
|
|
|
|
|
|
|
LINK_LIBS
|
2020-06-17 02:43:55 +08:00
|
|
|
clangTidy
|
|
|
|
clangTidyUtils
|
2020-06-23 23:48:04 +08:00
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
omp_gen
|
2020-06-17 02:43:55 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
clang_target_link_libraries(clangTidyReadabilityModule
|
|
|
|
PRIVATE
|
2019-10-03 06:39:46 +08:00
|
|
|
clangAnalysis
|
2014-09-22 18:41:39 +08:00
|
|
|
clangAST
|
|
|
|
clangASTMatchers
|
|
|
|
clangBasic
|
|
|
|
clangLex
|
|
|
|
clangTooling
|
|
|
|
)
|