[PATCH] D105533: [clang] Fix an infinite loop during typo-correction
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 8 12:00:16 PDT 2021
hokein updated this revision to Diff 357313.
hokein marked an inline comment as done.
hokein added a comment.
refine the fix based on the discussion: https://bugs.llvm.org/show_bug.cgi?id=50797#c13
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105533/new/
https://reviews.llvm.org/D105533
Files:
clang/lib/Sema/SemaExprCXX.cpp
clang/test/Sema/typo-correction-ambiguity.c
clang/test/Sema/typo-correction-no-hang.c
Index: clang/test/Sema/typo-correction-no-hang.c
===================================================================
--- /dev/null
+++ clang/test/Sema/typo-correction-no-hang.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR50797
+struct a {
+ int xxx;
+};
+
+int g_107;
+int g_108;
+int g_109;
+
+struct a g_999; // expected-note 2{{'g_999' declared here}}
+
+void b() { (g_910.xxx = g_910.xxx); } //expected-error 2{{use of undeclared identifier 'g_910'; did you mean 'g_999'}}
Index: clang/test/Sema/typo-correction-ambiguity.c
===================================================================
--- clang/test/Sema/typo-correction-ambiguity.c
+++ clang/test/Sema/typo-correction-ambiguity.c
@@ -12,3 +12,16 @@
v_2_0(v_195, // expected-error {{use of undeclared identifier 'v_195'}}
v_231); // expected-error {{use of undeclared identifier 'v_231'}}
}
+
+// Test: no typo-correction diagnostics are emitted for ambiguous typos.
+struct a {
+ int xxx;
+};
+
+int g_107;
+int g_108;
+int g_109;
+
+struct a g_999;
+struct a g_998;
+void PR50797() { (g_910.xxx = g_910.xxx); } //expected-error 2{{use of undeclared identifier 'g_910'}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -8343,6 +8343,7 @@
AmbiguousTypoExprs.remove(TE);
SemaRef.getTypoExprState(TE).Consumer->restoreSavedPosition();
+ TransformCache[TE] = SavedTransformCache[TE];
}
TransformCache = std::move(SavedTransformCache);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105533.357313.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210708/2a949cc0/attachment.bin>
More information about the cfe-commits
mailing list