[PATCH] D80896: [clang-tidy][misc-redundant-expression] Fix crash on CXXFoldExpr

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 1 00:29:36 PDT 2020


njames93 added a comment.

This fix has expanded from preventing the crash to adding support for `CXXFoldExpr` to misc-redundant-expression. Maybe rename the revision to explain that better. 
If that is the case then you may as well add a test case showing a redundant fold expression



================
Comment at: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp:75
   while (LeftIter != Left->child_end() && RightIter != Right->child_end()) {
-    if (!areEquivalentExpr(dyn_cast<Expr>(*LeftIter),
+    if (*LeftIter && *RightIter &&
+        !areEquivalentExpr(dyn_cast<Expr>(*LeftIter),
----------------
What happens when `*LeftIter` is null, but `*RightIter` isn't or vice versa, That case should also return false.


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

https://reviews.llvm.org/D80896





More information about the cfe-commits mailing list