llvm-project/clang-tools-extra/unittests
Richard 99217fa8a0 [clang-tidy] Recognize labelled statements when simplifying boolean exprs
Inside a switch the caseStmt() and defaultStmt() have a nested statement
associated with them.  Similarly, labelStmt() has a nested statement.
These statements were being missed when looking for a compound-if of the
form "if (x) return true; return false;" when the if is nested under one
of these labelling constructs.

Enhance the matchers to look for these nested statements using some
private matcher hasSubstatement() traversal matcher on case, default
and label statements.  Add the private matcher hasSubstatementSequence()
to match the compound "if (x) return true; return false;" pattern.

- Add unit tests for private matchers and corresponding test
  infrastructure
- Add corresponding test file readability-simplify-bool-expr-case.cpp.
- Fix variable name copy/paste error in readability-simplify-bool-expr.cpp.
- Drop the asserts, which were used only for debugging matchers.
- Run clang-format on the whole check.
- Move local functions out of anonymous namespace and declare state, per
  LLVM style guide
- Declare labels constexpr
- Declare visitor arguments as pointer to const
- Drop braces around simple control statements per LLVM style guide
- Prefer explicit arguments over default arguments to methods

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

Fixes #27078
2022-01-28 16:09:46 -07:00
..
clang-apply-replacements [libtooling][clang-tidy] Fix diagnostics not highlighting fed SourceRanges 2021-04-10 16:43:44 +02:00
clang-change-namespace [clang-change-namespace] As part of using inclusive language 2020-06-19 23:01:42 -07:00
clang-doc [OpenMP] "UnFix" layering problem with FrontendOpenMP 2020-04-07 14:41:18 -05:00
clang-include-fixer [OpenMP] "UnFix" layering problem with FrontendOpenMP 2020-04-07 14:41:18 -05:00
clang-move [clang-move] Fix unit tests with forward slash as separator on windows 2021-11-08 22:21:31 +02:00
clang-query [clang-query] Add check to prevent setting srcloc when no introspection is available. 2021-04-28 11:21:35 +01:00
clang-tidy [clang-tidy] Recognize labelled statements when simplifying boolean exprs 2022-01-28 16:09:46 -07:00
include/common
CMakeLists.txt Use INTERFACE_COMPILE_OPTIONS to disable -Wsuggest-override for any target that links to gtest 2020-07-27 08:37:01 -07:00