aaron.ballman added inline comments.

================
Comment at: 
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp:85
   // remove the inner `if`.
-  const auto *BinOpCond = dyn_cast<BinaryOperator>(InnerIf->getCond());
+  const auto *BinOpCond = dyn_cast_or_null<BinaryOperator>(InnerIf->getCond());
+  if (!BinOpCond)
----------------
Under what circumstances does `getCond()` return `nullptr`?


================
Comment at: 
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp:90
+      BinOpCond = dyn_cast_or_null<BinaryOperator>(
+          *ExprWithCleanupsCond->children().begin());
+
----------------
You can call `ExprWithCleanupsCond->getSubExpr()` to do this more cleanly -- 
but similar question here as above -- what circumstances lead to a null sub 
expression?


================
Comment at: 
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp:138
   } else {
-    const auto *CondOp = cast<BinaryOperator>(InnerIf->getCond());
+    const auto *CondOp = dyn_cast_or_null<BinaryOperator>(InnerIf->getCond());
+    if (!CondOp)
----------------
Same feedback here as above.


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

https://reviews.llvm.org/D91037

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to