aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2011-09-14 19:37:32 +0000
committerKaelyn Uhrain <rikka@google.com>2011-09-14 19:37:32 +0000
commit7c24334bedf59bd9af57ee53eb8f6d9f6a50ca9b (patch)
tree5e93a490e612f040394585ae80dc2f62017a8339 /lib/Sema/SemaDecl.cpp
parentf45b357c0d0df99e160a6320e279ef788dd91ba6 (diff)
Plug an abstraction leak and fix a crasher in DiagnoseInvalidRedeclaration
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 96531d4145..abc3cf1938 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4284,8 +4284,6 @@ static void DiagnoseInvalidRedeclaration(Sema &S, FunctionDecl *NewFD,
} else if ((Correction = S.CorrectTypo(Prev.getLookupNameInfo(),
Prev.getLookupKind(), 0, 0, DC)) &&
Correction.getCorrection() != Name) {
- DiagMsg = isFriendDecl ? diag::err_no_matching_local_friend_suggest
- : diag::err_member_def_does_not_match_suggest;
for (TypoCorrection::decl_iterator CDecl = Correction.begin(),
CDeclEnd = Correction.end();
CDecl != CDeclEnd; ++CDecl) {
@@ -4299,8 +4297,15 @@ static void DiagnoseInvalidRedeclaration(Sema &S, FunctionDecl *NewFD,
NearMatches.push_back(std::make_pair(FD, ParamNum));
}
}
+ if (!NearMatches.empty())
+ DiagMsg = isFriendDecl ? diag::err_no_matching_local_friend_suggest
+ : diag::err_member_def_does_not_match_suggest;
}
+ // Ignore the correction if it didn't yield any close FunctionDecl matches
+ if (Correction && NearMatches.empty())
+ Correction = TypoCorrection();
+
if (Correction)
S.Diag(NewFD->getLocation(), DiagMsg)
<< Name << DC << Correction.getQuoted(S.getLangOptions())