Convert DiagnoseEmptyLookup to use correction callbacks.

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
This commit is contained in:
Kaelyn Uhrain 2012-01-18 05:58:54 +00:00
Родитель 4c3fc9b38d
Коммит 4798f8dfdb
4 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -2372,7 +2372,7 @@ public:
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);

Просмотреть файл

@ -1487,7 +1487,7 @@ Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
///
/// \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();
@ -1602,7 +1602,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
// 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());
@ -1817,7 +1817,8 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
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() &&

Просмотреть файл

@ -4880,9 +4880,11 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
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) {

Просмотреть файл

@ -9030,10 +9030,13 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
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();