r292927 - [Sema] Fix assumption about typo corrections containing no decl.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 24 04:49:59 PST 2017
Author: d0k
Date: Tue Jan 24 06:49:59 2017
New Revision: 292927
URL: http://llvm.org/viewvc/llvm-project?rev=292927&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=292927&r1=292926&r2=292927&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jan 24 06:49:59 2017
@@ -9169,15 +9169,18 @@ NamedDecl *Sema::BuildUsingDeclaration(S
HasTypenameKeyword, IsInstantiation, SS.getScopeRep(),
dyn_cast<CXXRecordDecl>(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<CXXRecordDecl>(ND);
if (RD && RD->isInjectedClassName()) {
More information about the cfe-commits
mailing list