summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2011-07-12 08:45:31 +0000
committerHans Wennborg <hans@hanshq.net>2011-07-12 08:45:31 +0000
commit38198ded24b7e1bb2ce736fde5ac367d4429ad14 (patch)
tree1c038601f3fcd7955b8f69c5bed1e1e1105fa474
parentccc50d7cf49bc9af543129849851932d2485d129 (diff)
downloadbcm5719-llvm-38198ded24b7e1bb2ce736fde5ac367d4429ad14.tar.gz
bcm5719-llvm-38198ded24b7e1bb2ce736fde5ac367d4429ad14.zip
Fix typo correction crash on overloaded functions, pr10283.
It would be cool if we could do overload resolution to suggest the right function, but at least this fixes the crashing. llvm-svn: 134976
-rw-r--r--clang/lib/Sema/SemaExpr.cpp3
-rw-r--r--clang/lib/Sema/SemaLookup.cpp3
-rw-r--r--clang/test/SemaCXX/function-overload-typo-crash.cpp12
3 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2fa7b2515ef..1e04ac734e6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1404,8 +1404,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
R.setLookupName(Corrected.getCorrection());
- if (!Corrected.isKeyword()) {
- NamedDecl *ND = Corrected.getCorrectionDecl();
+ if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
R.addDecl(ND);
if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND)) {
if (SS.isEmpty())
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 0ecd81400b0..7d075db0c44 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3744,6 +3744,8 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
case LookupResult::FoundOverloaded:
case LookupResult::FoundUnresolvedValue:
I->second.setCorrectionDecl(TmpRes.getAsSingle<NamedDecl>());
+ // FIXME: This sets the CorrectionDecl to NULL for overloaded functions.
+ // It would be nice to find the right one with overload resolution.
++I;
break;
}
@@ -3835,7 +3837,6 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
// wasn't actually in scope.
if (ED == 0 && Result.isKeyword()) return TypoCorrection();
- assert(Result.isResolved() && "correction has not been looked up");
// Record the correction for unqualified lookup.
if (IsUnqualifiedLookup)
UnqualifiedTyposCorrected[Typo] = Result;
diff --git a/clang/test/SemaCXX/function-overload-typo-crash.cpp b/clang/test/SemaCXX/function-overload-typo-crash.cpp
new file mode 100644
index 00000000000..0fea312a97f
--- /dev/null
+++ b/clang/test/SemaCXX/function-overload-typo-crash.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR10283
+void min();
+void min(int);
+
+template <typename T> void max(T);
+
+void f() {
+ fin(); //expected-error {{use of undeclared identifier 'fin'; did you mean 'min'}}
+ fax(0); //expected-error {{use of undeclared identifier 'fax'; did you mean 'max'}}
+}
OpenPOWER on IntegriCloud