diff options
author | Kaelyn Uhrain <rikka@google.com> | 2012-04-03 18:20:11 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2012-04-03 18:20:11 +0000 |
commit | f4657d5bd7df0a8da1e0743ddedbe3254852c7a9 (patch) | |
tree | 53fe73755d71c15832043d85ef25514e3fe4e2e5 /clang/lib/Sema | |
parent | b81e2b403cd40d4ea8236358c3bb3abf9302e31f (diff) | |
download | bcm5719-llvm-f4657d5bd7df0a8da1e0743ddedbe3254852c7a9.tar.gz bcm5719-llvm-f4657d5bd7df0a8da1e0743ddedbe3254852c7a9.zip |
Replace the workaround from r153445 with a proper fix.
Infinite recursion was happening when DiagnoseInvalidRedeclaration
called ActOnFunctionDeclarator to check if a typo correction works when
the correction was just to the nested-name-specifier because the wrong
DeclContext was being passed in. Unlike a number of functions
surrounding typo correction, the DeclContext passed in for a function is
the context of the function name after applying any nested name
specifiers, not the lexical DeclContext where the
function+nested-name-specifier appears.
llvm-svn: 153962
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 2 |
2 files changed, 7 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index cc75f3f4aa3..12b9a630252 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4500,14 +4500,7 @@ namespace { class DifferentNameValidatorCCC : public CorrectionCandidateCallback { public: DifferentNameValidatorCCC(CXXRecordDecl *Parent) - : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) { - // Don't allow any additional qualification. - // FIXME: It would be nice to perform this additional qualification. - // However, DiagnoseInvalidRedeclaration is unable to handle the - // qualification, because it doesn't know how to pass the corrected - // nested-name-specifier through to ActOnFunctionDeclarator. - AllowAddedQualifier = false; - } + : ExpectedParent(Parent ? Parent->getCanonicalDecl() : 0) {} virtual bool ValidateCandidate(const TypoCorrection &candidate) { if (candidate.getEditDistance() == 0) @@ -4596,12 +4589,11 @@ static NamedDecl* DiagnoseInvalidRedeclaration( // TODO: Refactor ActOnFunctionDeclarator so that we can call only the // pieces need to verify the typo-corrected C++ declaraction and hopefully // eliminate the need for the parameter pack ExtraArgs. - Result = SemaRef.ActOnFunctionDeclarator(ExtraArgs.S, ExtraArgs.D, - NewFD->getDeclContext(), - NewFD->getTypeSourceInfo(), - Previous, - ExtraArgs.TemplateParamLists, - ExtraArgs.AddToScope); + Result = SemaRef.ActOnFunctionDeclarator( + ExtraArgs.S, ExtraArgs.D, + Correction.getCorrectionDecl()->getDeclContext(), + NewFD->getTypeSourceInfo(), Previous, ExtraArgs.TemplateParamLists, + ExtraArgs.AddToScope); if (Trap.hasErrorOccurred()) { // Pretend the typo correction never occurred ExtraArgs.D.SetIdentifier(Name.getAsIdentifierInfo(), diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index a8d7b1e971b..adbfedc6415 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -3815,7 +3815,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName, // Determine whether we are going to search in the various namespaces for // corrections. bool SearchNamespaces - = getLangOpts().CPlusPlus && CCC.AllowAddedQualifier && + = getLangOpts().CPlusPlus && (IsUnqualifiedLookup || (QualifiedDC && QualifiedDC->isNamespace())); if (IsUnqualifiedLookup || SearchNamespaces) { |