[PATCH] D149015: [clang-tidy] Added bugprone-inc-dec-in-conditions check

Shivam Gupta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 27 23:56:19 PDT 2023


xgupta added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/IncDecInConditionsCheck.cpp:30
+void IncDecInConditionsCheck::registerMatchers(MatchFinder *Finder) {
+  auto OperatorMacher = expr(
+      anyOf(binaryOperator(anyOf(isComparisonOperator(), isLogicalOperator())),
----------------
OperatorMacher  missing t in its spelling.


================
Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:141
 
+struct NotIdenticalStatementsPredicate {
+  bool
----------------
A comment can be here for this struct.




================
Comment at: clang-tools-extra/clang-tidy/utils/Matchers.h:150
+
+AST_MATCHER_P(Stmt, isStatementIdenticalToBoundNode, std::string, ID) {
+  NotIdenticalStatementsPredicate Predicate;
----------------
A comment can be here for this matcher.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone/inc-dec-in-conditions.rst:62
+means that if ``i`` were initially ``5``, the first operand ``i < 5`` would
+evaluate to ``false`` and the second operand ``i > 2`` would not be evaluated.
+As a result, the decrement operation ``--i`` would not be executed and ``i``
----------------
If it is false then the second statement will be evaluated, right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149015/new/

https://reviews.llvm.org/D149015



More information about the cfe-commits mailing list