]> granicus.if.org Git - clang/commitdiff
Convert DiagnoseEmptyLookup to use correction callbacks.
authorKaelyn Uhrain <rikka@google.com>
Wed, 18 Jan 2012 05:58:54 +0000 (05:58 +0000)
committerKaelyn Uhrain <rikka@google.com>
Wed, 18 Jan 2012 05:58:54 +0000 (05:58 +0000)
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

include/clang/Sema/Sema.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp

index 482f12c719680154e8d0d10953e65e749b02ff34..238b0edec6ac002963aa8a0ec7c66cb6ab4cc46f 100644 (file)
@@ -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);
 
index 3eda4209402a7a46d2f0ffc06a0e404cd80618a1..119151a3af7857e2e940b6c19bec957d19d97970 100644 (file)
@@ -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() &&
index fceb6398077b70109429b8fe490852dbedefa274..db41f5a3ca7e8c974617a5319cc22134538f0f0a 100644 (file)
@@ -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) {
index 3708f6c9d0865854084c5036ad8301a949220ec8..d800e9382008d77451195ce7a588ae25e4bf9a28 100644 (file)
@@ -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();