diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp index c8f7bae67f8..bb4cd6cfa4a 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp @@ -126,10 +126,15 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) { (OpCode == BinaryOperatorKind::BO_LE && Value == 0 && !ContainerIsLHS)) return; - // Do not warn for size > 1, 1 < size. - if ((OpCode == BinaryOperatorKind::BO_GT && Value == 1 && ContainerIsLHS) || - (OpCode == BinaryOperatorKind::BO_LT && Value == 1 && !ContainerIsLHS)) - return; + // Do not warn for size > 1, 1 < size, size <= 1, 1 >= size. + if (Value == 1) { + if ((OpCode == BinaryOperatorKind::BO_GT && ContainerIsLHS) || + (OpCode == BinaryOperatorKind::BO_LT && !ContainerIsLHS)) + return; + if ((OpCode == BinaryOperatorKind::BO_LE && ContainerIsLHS) || + (OpCode == BinaryOperatorKind::BO_GE && !ContainerIsLHS)) + return; + } if (OpCode == BinaryOperatorKind::BO_NE && Value == 0) Negation = true; |

