No new unit tests yet as there is no behavioral change
(except for slightly more specific filtering in
Sema::ActOnStartOfLambdaDefinition). Tests will be added
as the code paths are traced in greater depth to determine
how to improve the results--there are at least one or two
known bugs that require those improvements. This commit
lays the groundwork for those changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148382
91177308-0d34-0410-b5e6-
96231b3b80d8
const TemplateArgumentListInfo *&TemplateArgs);
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
- CorrectTypoContext CTC = CTC_Unknown,
+ CorrectionCandidateCallback &CCC,
TemplateArgumentListInfo *ExplicitTemplateArgs = 0,
Expr **Args = 0, unsigned NumArgs = 0);
///
/// \return false if new lookup candidates were found
bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
- CorrectTypoContext CTC,
+ CorrectionCandidateCallback &CCC,
TemplateArgumentListInfo *ExplicitTemplateArgs,
Expr **Args, unsigned NumArgs) {
DeclarationName Name = R.getLookupName();
// We didn't find anything, so try to correct for a typo.
TypoCorrection Corrected;
if (S && (Corrected = CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(),
- S, &SS, NULL, false, CTC))) {
+ S, &SS, &CCC))) {
std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
R.setLookupName(Corrected.getCorrection());
return ActOnDependentIdExpression(SS, NameInfo, IsAddressOfOperand,
TemplateArgs);
- if (DiagnoseEmptyLookup(S, SS, R, CTC_Unknown))
+ CorrectionCandidateCallback DefaultValidator;
+ if (DiagnoseEmptyLookup(S, SS, R, DefaultValidator))
return ExprError();
assert(!R.empty() &&
LookupParsedName(R, CurScope, &ScopeSpec);
if (R.isAmbiguous())
continue;
- if (R.empty())
- if (DiagnoseEmptyLookup(CurScope, ScopeSpec, R, CTC_Unknown))
+ if (R.empty()) {
+ DeclFilterCCC<VarDecl> Validator;
+ if (DiagnoseEmptyLookup(CurScope, ScopeSpec, R, Validator))
continue;
+ }
VarDecl *Var = R.getAsSingle<VarDecl>();
if (!Var) {
LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
Sema::LookupOrdinaryName);
+ CorrectionCandidateCallback Validator;
+ Validator.WantTypeSpecifiers = SemaRef.getLangOptions().CPlusPlus;
+ Validator.WantRemainingKeywords = false;
if (!DiagnoseTwoPhaseLookup(SemaRef, Fn->getExprLoc(), SS, R,
ExplicitTemplateArgs, Args, NumArgs) &&
(!EmptyLookup ||
- SemaRef.DiagnoseEmptyLookup(S, SS, R, Sema::CTC_Expression,
+ SemaRef.DiagnoseEmptyLookup(S, SS, R, Validator,
ExplicitTemplateArgs, Args, NumArgs)))
return ExprError();