From: Benjamin Kramer Date: Tue, 24 Jan 2017 12:49:59 +0000 (+0000) Subject: [Sema] Fix assumption about typo corrections containing no decl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2df980329800d5a16e8638c4a5e7b0ace7cdbe03;p=clang [Sema] Fix assumption about typo corrections containing no decl. This can happen when the typo correction is coming from an external sema source. Test case will follow in clang-tools-extra. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292927 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index f265f4c00f..671d3251a5 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -9169,15 +9169,18 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS, HasTypenameKeyword, IsInstantiation, SS.getScopeRep(), dyn_cast(CurContext)), CTK_ErrorRecovery)) { - // We reject any correction for which ND would be NULL. - NamedDecl *ND = Corrected.getCorrectionDecl(); - // We reject candidates where DroppedSpecifier == true, hence the // literal '0' below. diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest) << NameInfo.getName() << LookupContext << 0 << SS.getRange()); + // If we picked a correction with no attached Decl we can't do anything + // useful with it, bail out. + NamedDecl *ND = Corrected.getCorrectionDecl(); + if (!ND) + return BuildInvalid(); + // If we corrected to an inheriting constructor, handle it as one. auto *RD = dyn_cast(ND); if (RD && RD->isInjectedClassName()) {