[clang] 16ca711 - [clang] Fix a typo-correction crash
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 22 11:21:39 PDT 2020
Author: Haojian Wu
Date: 2020-09-22T20:21:21+02:00
New Revision: 16ca711803300bd966acf8759876a1ccd478c616
URL: https://github.com/llvm/llvm-project/commit/16ca711803300bd966acf8759876a1ccd478c616
DIFF: https://github.com/llvm/llvm-project/commit/16ca711803300bd966acf8759876a1ccd478c616.diff
LOG: [clang] Fix a typo-correction crash
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.
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D87815
Added:
Modified:
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/typo-correction-crash.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 736a6c166eb3..9cd5a35660d9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6068,8 +6068,6 @@ static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args) {
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;
diff --git a/clang/test/SemaCXX/typo-correction-crash.cpp b/clang/test/SemaCXX/typo-correction-crash.cpp
index fce10800f2b6..10c0c11aaa6b 100644
--- a/clang/test/SemaCXX/typo-correction-crash.cpp
+++ b/clang/test/SemaCXX/typo-correction-crash.cpp
@@ -32,3 +32,12 @@ FooRecord::NestedNamespace::type x; // expected-error {{no member named 'NestedN
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}}
+ }
+};
+}
More information about the cfe-commits
mailing list