aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2012-01-18 05:58:54 +0000
committerKaelyn Uhrain <rikka@google.com>2012-01-18 05:58:54 +0000
commit4798f8dfdb15fc03fa6b4104efed8762d52ebb18 (patch)
tree9d2df7fbbe37f8a2565e2dc49f30b142382f720e
parent4c3fc9b38d3723f73e4ded594cebf38c76f91d93 (diff)
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
-rw-r--r--include/clang/Sema/Sema.h2
-rw-r--r--lib/Sema/SemaExpr.cpp7
-rw-r--r--lib/Sema/SemaExprCXX.cpp6
-rw-r--r--lib/Sema/SemaOverload.cpp5
4 files changed, 13 insertions, 7 deletions
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 482f12c719..238b0edec6 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -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);
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3eda420940..119151a3af 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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() &&
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index fceb639807..db41f5a3ca 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -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) {
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 3708f6c9d0..d800e93820 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -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();