[PATCH] D87815: [clang] Fix a typo-correction crash
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 17 00:56:52 PDT 2020
hokein created this revision.
hokein added a reviewer: rsmith.
Herald added a project: clang.
hokein requested review of this revision.
We leave a dangling TypoExpr when typo-correction is performed
successfully in `checkArgsForPlaceholders`, which leads a crash in the
later TypoCorrection.
This code was added in https://github.com/llvm/llvm-project/commit/1586782767938df3a20f7abc4d8335c48b100bc4,
and it didn't seem to have enough test coverage.
The fix is to remove this part, and no failuer tests.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87815
Files:
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/typo-correction-crash.cpp
Index: clang/test/SemaCXX/typo-correction-crash.cpp
===================================================================
--- clang/test/SemaCXX/typo-correction-crash.cpp
+++ clang/test/SemaCXX/typo-correction-crash.cpp
@@ -32,3 +32,12 @@
void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error {{undeclared identifier '_test_'}}
+
+namespace NoCrash {
+class S {
+ void Function(int a) {
+ unknown1(unknown2, Function, unknown3); // expected-error 2{{use of undeclared identifier}} \
+ expected-error {{reference to non-static member function must be called}}
+ }
+};
+}
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6068,8 +6068,6 @@
ExprResult result = S.CheckPlaceholderExpr(args[i]);
if (result.isInvalid()) hasInvalid = true;
else args[i] = result.get();
- } else if (hasInvalid) {
- (void)S.CorrectDelayedTyposInExpr(args[i]);
}
}
return hasInvalid;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87815.292420.patch
Type: text/x-patch
Size: 1180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200917/989e8a1c/attachment.bin>
More information about the cfe-commits
mailing list