hanchenye-llvm-project/clang-tools-extra/clang-tidy/misc
Gabor Horvath ec87e17c84 [clang-tidy] Misc redundant expressions checker updated for macros
Redundant Expression Checker is updated to be able to detect expressions that
contain macros. Also, other small details are modified to improve the current
implementation.

The improvements in detail are as follows:
* Binary and ternary operator expressions containing two constants, with at
least one of them from a macro, are detected and tested for redundancy.

Macro expressions are treated somewhat differently from other expressions,
because the particular values of macros can vary across builds.
They can be considered correct and intentional, even if macro values equal,
produce ranges that exclude each other or fully overlap, etc. 

* The code structure is slightly modified: typos are corrected,
comments are added and some functions are renamed to improve comprehensibility,
both in the checker and the test file. A few test cases are moved to another
function.

* The checker is now able to detect redundant CXXFunctionalCastExprs as well.
A corresponding test case is added.

Patch by: Lilla Barancsuk!

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

llvm-svn: 317570
2017-11-07 13:17:58 +00:00
..
ArgumentCommentCheck.cpp [clang-tidy] misc-argument-comment - extended gmock support 2017-02-07 11:39:56 +00:00
ArgumentCommentCheck.h [clang-tidy] misc-argument-comment support for gmock 2017-02-06 15:47:17 +00:00
AssertSideEffectCheck.cpp
AssertSideEffectCheck.h
BoolPointerImplicitConversionCheck.cpp Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs} 2016-12-13 16:19:19 +00:00
BoolPointerImplicitConversionCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
CMakeLists.txt [clang-tidy] check for __func__/__FUNCTION__ in lambdas 2017-06-02 17:36:32 +00:00
DanglingHandleCheck.cpp Adapt clang-tidy checks to changing semantics of hasDeclaration. 2017-08-02 13:13:11 +00:00
DanglingHandleCheck.h
DefinitionsInHeadersCheck.cpp Fix up clang-tidy after clang r314037. 2017-09-22 23:47:20 +00:00
DefinitionsInHeadersCheck.h
FoldInitTypeCheck.cpp
FoldInitTypeCheck.h
ForwardDeclarationNamespaceCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ForwardDeclarationNamespaceCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ForwardingReferenceOverloadCheck.cpp [clang-tidy] Do not dereference a null BaseType 2017-05-23 16:19:04 +00:00
ForwardingReferenceOverloadCheck.h [clang-tidy] Check for forwarding reference overload in constructors. 2017-04-06 09:56:42 +00:00
InaccurateEraseCheck.cpp Adapt clang-tidy checks to changing semantics of hasDeclaration. 2017-08-02 13:13:11 +00:00
InaccurateEraseCheck.h
IncorrectRoundings.cpp Replace APFloatBase static fltSemantics data members with getter functions 2016-12-14 11:57:17 +00:00
IncorrectRoundings.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
InefficientAlgorithmCheck.cpp
InefficientAlgorithmCheck.h
LambdaFunctionNameCheck.cpp [clang-tidy] check for __func__/__FUNCTION__ in lambdas 2017-06-02 17:36:32 +00:00
LambdaFunctionNameCheck.h [clang-tidy] Add `const` to operator() to fix a warning. 2017-06-02 18:47:50 +00:00
MacroParenthesesCheck.cpp [NFC] Update function call names as changed in MacroInfo that should refer to Parameters (as opposed to Arguments). 2017-07-17 17:20:57 +00:00
MacroParenthesesCheck.h
MacroRepeatedSideEffectsCheck.cpp [NFC] Update function call names as changed in MacroInfo that should refer to Parameters (as opposed to Arguments). 2017-07-17 17:20:57 +00:00
MacroRepeatedSideEffectsCheck.h
MiscTidyModule.cpp [clang-tidy] check for __func__/__FUNCTION__ in lambdas 2017-06-02 17:36:32 +00:00
MisplacedConstCheck.cpp
MisplacedConstCheck.h
MisplacedWideningCastCheck.cpp [clang-tidy] Fix 'misc-misplaced-widening-cast' assertion error. 2017-08-29 06:25:24 +00:00
MisplacedWideningCastCheck.h
MoveConstantArgumentCheck.cpp [clang-tidy] misc-move-const-arg shouldn't complain on std::move(lambda) 2017-05-22 14:30:14 +00:00
MoveConstantArgumentCheck.h
MoveConstructorInitCheck.cpp [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
MoveConstructorInitCheck.h [clang-tidy] Remove duplicated check from move-constructor-init 2016-12-17 20:23:14 +00:00
MoveForwardingReferenceCheck.cpp modernize-use-auto NFC fixes 2016-12-14 15:29:23 +00:00
MoveForwardingReferenceCheck.h
MultipleStatementMacroCheck.cpp modernize-use-auto NFC fixes 2016-12-14 15:29:23 +00:00
MultipleStatementMacroCheck.h
NewDeleteOverloadsCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NewDeleteOverloadsCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NoexceptMoveConstructorCheck.cpp Revert "[clang-tidy] When" -fno-exceptions is used", this warning is better to be suppressed." 2017-06-09 07:34:58 +00:00
NoexceptMoveConstructorCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NonCopyableObjects.cpp [clang-tidy] Simplify matchers 2016-11-08 05:58:07 +00:00
NonCopyableObjects.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
RedundantExpressionCheck.cpp [clang-tidy] Misc redundant expressions checker updated for macros 2017-11-07 13:17:58 +00:00
RedundantExpressionCheck.h [clang-tidy] Misc redundant expressions checker updated for macros 2017-11-07 13:17:58 +00:00
SizeofContainerCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
SizeofContainerCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
SizeofExpressionCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
SizeofExpressionCheck.h
StaticAssertCheck.cpp [clang-tidy] Make misc-static-assert accept assert(!"msg") 2017-06-03 10:13:55 +00:00
StaticAssertCheck.h
StringCompareCheck.cpp [clang-tidy] Add check 'misc-string-compare'. 2016-12-30 10:09:46 +00:00
StringCompareCheck.h [clang-tidy] Add check 'misc-string-compare'. 2016-12-30 10:09:46 +00:00
StringConstructorCheck.cpp
StringConstructorCheck.h
StringIntegerAssignmentCheck.cpp
StringIntegerAssignmentCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
StringLiteralWithEmbeddedNulCheck.cpp
StringLiteralWithEmbeddedNulCheck.h
SuspiciousEnumUsageCheck.cpp [clang-tidy] SuspiciousEnumUsageCheck bugfix 2017-09-12 09:40:13 +00:00
SuspiciousEnumUsageCheck.h [clang-tidy] Add enum misuse check. 2016-12-27 10:07:39 +00:00
SuspiciousMissingCommaCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
SuspiciousMissingCommaCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
SuspiciousSemicolonCheck.cpp [clang-tidy] hasErrorOccurred() -> hasUncompilableErrorOccurred() 2017-02-08 16:11:22 +00:00
SuspiciousSemicolonCheck.h
SuspiciousStringCompareCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
SuspiciousStringCompareCheck.h
SwappedArgumentsCheck.cpp Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs} 2016-12-13 16:19:19 +00:00
SwappedArgumentsCheck.h
ThrowByValueCatchByReferenceCheck.cpp [clang-tidy] Fix diag message for catch-by-value 2017-03-23 15:17:44 +00:00
ThrowByValueCatchByReferenceCheck.h
UnconventionalAssignOperatorCheck.cpp [clang-tidy] Don't warn about call to unresolved operator* 2017-02-15 14:01:41 +00:00
UnconventionalAssignOperatorCheck.h
UndelegatedConstructor.cpp Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs} 2016-12-13 16:19:19 +00:00
UndelegatedConstructor.h
UniqueptrResetReleaseCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UniqueptrResetReleaseCheck.h
UnusedAliasDeclsCheck.cpp
UnusedAliasDeclsCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UnusedParametersCheck.cpp [clang-tidy] Fixed misc-unused-parameters omitting parameters square brackets 2017-09-15 11:28:28 +00:00
UnusedParametersCheck.h [clang-tidy] Optimize misc-unused-parameters. NFCI 2017-05-17 02:25:11 +00:00
UnusedRAIICheck.cpp Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs} 2016-12-13 16:19:19 +00:00
UnusedRAIICheck.h
UnusedUsingDeclsCheck.cpp [clang-tidy] Fix misc-unused-using-decls false positives in presence of compile errors 2017-02-09 10:41:27 +00:00
UnusedUsingDeclsCheck.h
UseAfterMoveCheck.cpp Adapt clang-tidy checks to changing semantics of hasDeclaration. 2017-08-02 13:13:11 +00:00
UseAfterMoveCheck.h
VirtualNearMissCheck.cpp [clang-tidy] Don't compute the edit distance if it's over the threshold. 2017-08-09 22:09:29 +00:00
VirtualNearMissCheck.h [clang-tidy] Use a more efficient map for the virtual near miss check. 2017-10-10 07:21:51 +00:00