Skip to content

Commit 7a2b704

Browse files
committed
[Sema][Typo Correction] Fix another infinite loop on ambiguity
See also: D67515 - For the given call expression we would end up repeatedly trying to transform the same expression over and over again - Fix is to keep the old TransformCache when checking for ambiguity Differential Revision: https://reviews.llvm.org/D69060
1 parent 5934cd1 commit 7a2b704

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7780,8 +7780,9 @@ class TransformTypos : public TreeTransform<TransformTypos> {
77807780

77817781
// If we found a valid result, double check to make sure it's not ambiguous.
77827782
if (!IsAmbiguous && !Res.isInvalid() && !AmbiguousTypoExprs.empty()) {
7783-
auto SavedTransformCache = std::move(TransformCache);
7784-
TransformCache.clear();
7783+
auto SavedTransformCache =
7784+
llvm::SmallDenseMap<TypoExpr *, ExprResult, 2>(TransformCache);
7785+
77857786
// Ensure none of the TypoExprs have multiple typo correction candidates
77867787
// with the same edit length that pass all the checks and filters.
77877788
while (!AmbiguousTypoExprs.empty()) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
// Check the following typo correction behavior in C:
4+
// - no typos are diagnosed when a call expression has ambiguous (multiple) corrections
5+
6+
int v_63;
7+
8+
void v_2_0(int v_452, int v_454) {}
9+
10+
int v_3_0() {
11+
for (int v_345 = 0 ; v_63;)
12+
v_2_0(v_195, // expected-error {{use of undeclared identifier 'v_195'}}
13+
v_231); // expected-error {{use of undeclared identifier 'v_231'}}
14+
}

0 commit comments

Comments
 (0)