[PATCH] D105533: [clang] Fix an infinite loop during typo-correction

David Goldman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 7 08:11:11 PDT 2021


dgoldman added inline comments.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:8340
           }
+          // Bail out if we didn't make any correction progress on the checking
+          // TypoExpr TE, otherwise we risk running the loop forever.
----------------
sammccall wrote:
> Comment is good but maybe could mention the high-level effect of breaking out (treat as unambiguous)
At this point we know the tree is so invalid that transforming no longer works, so our correction didn't really help. Is it even worth suggesting a correction (if we treat it as ambiguous we won't)?


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:8341-8344
+          // TypoExpr TE, otherwise we risk running the loop forever.
+          if (CurrentCorrection ==
+              &SemaRef.getTypoExprState(TE).Consumer->getCurrentCorrection())
+            break;
----------------
Is all of this needed - can you just change the while below to also be && Next != TC? Could move Next assignment up into the body if we want to change how we handle stalled progress


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105533



More information about the cfe-commits mailing list