summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2014-06-23 22:57:51 +0000
committerNick Lewycky <nicholas@mxc.ca>2014-06-23 22:57:51 +0000
commitee28b09421d031c938fe1526bcbbabdf0bf96c59 (patch)
tree2da435cd16920bf2f8273fee29cbd414cd98b7a8 /lib/Sema/SemaExpr.cpp
parent42988461bb266eb0359f136417498b44a9f786b6 (diff)
downloadclang-ee28b09421d031c938fe1526bcbbabdf0bf96c59.tar.gz
clang-ee28b09421d031c938fe1526bcbbabdf0bf96c59.tar.bz2
clang-ee28b09421d031c938fe1526bcbbabdf0bf96c59.tar.xz
Propagate isAddressOfMember into typo correction so that we don't correct &qualified-id into &unqualified-id. Also make sure to set the naming class when we find the qualified-id in a different class than the nested name specifier specified so far. Fixes PR19681!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211551 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index bda80cd205..c7ea55219a 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1883,6 +1883,17 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
}
}
R.addDecl(ND);
+ if (getLangOpts().CPlusPlus && ND->isCXXClassMember()) {
+ CXXRecordDecl *Record = nullptr;
+ if (Corrected.getCorrectionSpecifier()) {
+ const Type *Ty = Corrected.getCorrectionSpecifier()->getAsType();
+ Record = Ty->getAsCXXRecordDecl();
+ }
+ if (!Record)
+ Record = cast<CXXRecordDecl>(
+ ND->getDeclContext()->getRedeclContext());
+ R.setNamingClass(Record);
+ }
AcceptableWithRecovery =
isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND);
@@ -2100,6 +2111,9 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
// If this name wasn't predeclared and if this is not a function
// call, diagnose the problem.
CorrectionCandidateCallback DefaultValidator;
+ DefaultValidator.IsAddressOfOperand = IsAddressOfOperand;
+ assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
+ "Typo correction callback misconfigured");
if (DiagnoseEmptyLookup(S, SS, R, CCC ? *CCC : DefaultValidator))
return ExprError();