]> granicus.if.org Git - clang/commitdiff
Make the callback object to Sema::CorrectTypo mandatory.
authorKaelyn Uhrain <rikka@google.com>
Tue, 31 Jan 2012 23:49:25 +0000 (23:49 +0000)
committerKaelyn Uhrain <rikka@google.com>
Tue, 31 Jan 2012 23:49:25 +0000 (23:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149451 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/clang/Sema/Sema.h
lib/Sema/SemaCXXScopeSpec.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprMember.cpp
lib/Sema/SemaExprObjC.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateVariadic.cpp

index 3f8891d6ff0dc8ee78dc55eba4ec814c0ead393a..4d15ec4b1cee669a47c8996b951210a13e8093d3 100644 (file)
@@ -1786,7 +1786,7 @@ public:
   TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
                              Sema::LookupNameKind LookupKind,
                              Scope *S, CXXScopeSpec *SS,
-                             CorrectionCandidateCallback *CCC,
+                             CorrectionCandidateCallback &CCC,
                              DeclContext *MemberContext = 0,
                              bool EnteringContext = false,
                              const ObjCObjectPointerType *OPT = 0);
index 1468e45ab3aba1049d5c5c5fb844b3ce32abb6ab..c4d27e38735b7478e766098081f2cb1cdd993f63 100644 (file)
@@ -500,7 +500,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S,
     TypoCorrection Corrected;
     Found.clear();
     if ((Corrected = CorrectTypo(Found.getLookupNameInfo(),
-                                 Found.getLookupKind(), S, &SS, &Validator,
+                                 Found.getLookupKind(), S, &SS, Validator,
                                  LookupCtx, EnteringContext))) {
       std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
       std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
index c20f9426fbabbfc8819339a0fb044f84b2b90b31..d545d03ac5228d7985fd4657b56b13ed46f54154 100644 (file)
@@ -174,7 +174,7 @@ ParsedType Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
     if (CorrectedII) {
       TypeNameValidatorCCC Validator(true);
       TypoCorrection Correction = CorrectTypo(Result.getLookupNameInfo(),
-                                              Kind, S, SS, &Validator);
+                                              Kind, S, SS, Validator);
       IdentifierInfo *NewII = Correction.getCorrectionAsIdentifierInfo();
       TemplateTy Template;
       bool MemberOfUnknownSpecialization;
@@ -371,7 +371,7 @@ bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,
   TypeNameValidatorCCC Validator(false);
   if (TypoCorrection Corrected = CorrectTypo(DeclarationNameInfo(&II, IILoc),
                                              LookupOrdinaryName, S, SS,
-                                             &Validator)) {
+                                             Validator)) {
     std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
     std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
 
@@ -576,7 +576,7 @@ Corrected:
       CorrectionCandidateCallback DefaultValidator;
       if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
                                                  Result.getLookupKind(), S, 
-                                                 &SS, &DefaultValidator)) {
+                                                 &SS, DefaultValidator)) {
         unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
         unsigned QualifiedDiag = diag::err_no_member_suggest;
         std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
@@ -1274,7 +1274,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *&Id,
     DeclFilterCCC<ObjCInterfaceDecl> Validator;
     if (TypoCorrection C = CorrectTypo(DeclarationNameInfo(Id, IdLoc),
                                        LookupOrdinaryName, TUScope, NULL,
-                                       &Validator)) {
+                                       Validator)) {
       IDecl = C.getCorrectionDeclAs<ObjCInterfaceDecl>();
       Diag(IdLoc, diag::err_undef_interface_suggest)
         << Id << IDecl->getDeclName() 
@@ -4498,7 +4498,7 @@ static NamedDecl* DiagnoseInvalidRedeclaration(
   // If the qualified name lookup yielded nothing, try typo correction
   } else if ((Correction = SemaRef.CorrectTypo(Prev.getLookupNameInfo(),
                                          Prev.getLookupKind(), 0, 0,
-                                         &Validator, NewDC))) {
+                                         Validator, NewDC))) {
     // Trap errors.
     Sema::SFINAETrap Trap(SemaRef);
 
@@ -7359,7 +7359,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
     TypoCorrection Corrected;
     DeclFilterCCC<FunctionDecl> Validator;
     if (S && (Corrected = CorrectTypo(DeclarationNameInfo(&II, Loc),
-                                      LookupOrdinaryName, S, 0, &Validator))) {
+                                      LookupOrdinaryName, S, 0, Validator))) {
       std::string CorrectedStr = Corrected.getAsString(getLangOptions());
       std::string CorrectedQuotedStr = Corrected.getQuoted(getLangOptions());
       FunctionDecl *Func = Corrected.getCorrectionDeclAs<FunctionDecl>();
index 4852288ff4a0d2610a5852abc16cd50ca3a3c1ed..fd35733cf355765a80afa6a924ebd31302ce6041 100644 (file)
@@ -1882,7 +1882,7 @@ Sema::BuildMemInitializer(Decl *ConstructorD,
       MemInitializerValidatorCCC Validator(ClassDecl);
       if (R.empty() && BaseType.isNull() &&
           (Corr = CorrectTypo(R.getLookupNameInfo(), R.getLookupKind(), S, &SS,
-                              &Validator, ClassDecl))) {
+                              Validator, ClassDecl))) {
         std::string CorrectedStr(Corr.getAsString(getLangOptions()));
         std::string CorrectedQuotedStr(Corr.getQuoted(getLangOptions()));
         if (FieldDecl *Member = Corr.getCorrectionDeclAs<FieldDecl>()) {
@@ -5953,7 +5953,7 @@ static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc,
   R.clear();
   if (TypoCorrection Corrected = S.CorrectTypo(R.getLookupNameInfo(),
                                                R.getLookupKind(), Sc, &SS,
-                                               &Validator)) {
+                                               Validator)) {
     std::string CorrectedStr(Corrected.getAsString(S.getLangOptions()));
     std::string CorrectedQuotedStr(Corrected.getQuoted(S.getLangOptions()));
     if (DeclContext *DC = S.computeDeclContext(SS, false))
index 4394dbf9be1cc8f94f94e9bb1b981dbc73a8bfd4..ccb106fd8d36b7924449a2930d48908eddc26d54 100644 (file)
@@ -423,7 +423,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
       ObjCInterfaceValidatorCCC Validator(IDecl);
       if (TypoCorrection Corrected = CorrectTypo(
           DeclarationNameInfo(SuperName, SuperLoc), LookupOrdinaryName, TUScope,
-          NULL, &Validator)) {
+          NULL, Validator)) {
         PrevDecl = Corrected.getCorrectionDeclAs<ObjCInterfaceDecl>();
         Diag(SuperLoc, diag::err_undef_superclass_suggest)
           << SuperName << ClassName << PrevDecl->getDeclName();
@@ -655,7 +655,7 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations,
       DeclFilterCCC<ObjCProtocolDecl> Validator;
       TypoCorrection Corrected = CorrectTypo(
           DeclarationNameInfo(ProtocolId[i].first, ProtocolId[i].second),
-          LookupObjCProtocolName, TUScope, NULL, &Validator);
+          LookupObjCProtocolName, TUScope, NULL, Validator);
       if ((PDecl = Corrected.getCorrectionDeclAs<ObjCProtocolDecl>())) {
         Diag(ProtocolId[i].second, diag::err_undeclared_protocol_suggest)
           << ProtocolId[i].first << Corrected.getCorrection();
@@ -893,7 +893,7 @@ Decl *Sema::ActOnStartClassImplementation(
     ObjCInterfaceValidatorCCC Validator;
     if (TypoCorrection Corrected = CorrectTypo(
         DeclarationNameInfo(ClassName, ClassLoc), LookupOrdinaryName, TUScope,
-        NULL, &Validator)) {
+        NULL, Validator)) {
       // Suggest the (potentially) correct interface name. However, put the
       // fix-it hint itself in a separate note, since changing the name in 
       // the warning would make the fix-it change semantics.However, don't
index b79829b53f398de6d3af0ee28b7b7de9da920512..0d929f1836fb7108a4092f46c7a1b4c5f8164d36 100644 (file)
@@ -1611,7 +1611,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, &CCC))) {
+                                    S, &SS, CCC))) {
     std::string CorrectedStr(Corrected.getAsString(getLangOptions()));
     std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
     R.setLookupName(Corrected.getCorrection());
index 8f96089c18a9621c296de229626c4d2dc88a4599..fb1dbcef842fd777e9d6d7329254056b1de833c8 100644 (file)
@@ -583,7 +583,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
   RecordMemberExprValidatorCCC Validator;
   TypoCorrection Corrected = SemaRef.CorrectTypo(R.getLookupNameInfo(),
                                                  R.getLookupKind(), NULL,
-                                                 &SS, &Validator, DC);
+                                                 &SS, Validator, DC);
   R.clear();
   if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
     std::string CorrectedStr(
@@ -1124,7 +1124,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
       Validator.IsObjCIvarLookup = IsArrow;
       if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(),
                                                  LookupMemberName, NULL, NULL,
-                                                 &Validator, IDecl)) {
+                                                 Validator, IDecl)) {
         IV = Corrected.getCorrectionDeclAs<ObjCIvarDecl>();
         Diag(R.getNameLoc(),
              diag::err_typecheck_member_reference_ivar_suggest)
index a0a580c54799b3faf13d2f9384e0defcea4e9edc..4179ff870e8c4406ff1b3a3102c512c89da90012 100644 (file)
@@ -704,7 +704,7 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
   DeclFilterCCC<ObjCPropertyDecl> Validator;
   if (TypoCorrection Corrected = CorrectTypo(
       DeclarationNameInfo(MemberName, MemberLoc), LookupOrdinaryName, NULL,
-      NULL, &Validator, IFace, false, OPT)) {
+      NULL, Validator, IFace, false, OPT)) {
     ObjCPropertyDecl *Property =
         Corrected.getCorrectionDeclAs<ObjCPropertyDecl>();
     DeclarationName TypoResult = Corrected.getCorrection();
@@ -936,7 +936,7 @@ Sema::ObjCMessageKind Sema::getObjCMessageKind(Scope *S,
   ObjCInterfaceOrSuperCCC Validator(getCurMethodDecl());
   if (TypoCorrection Corrected = CorrectTypo(Result.getLookupNameInfo(),
                                              Result.getLookupKind(), S, NULL,
-                                             &Validator)) {
+                                             Validator)) {
     if (Corrected.isKeyword()) {
       // If we've found the keyword "super" (the only keyword that would be
       // returned by CorrectTypo), this is a send to super.
index 355cf46464d43c918268a62551d40ae0fdea4688..3da73b77bb8e240176c5c2965d162e36103ba7a8 100644 (file)
@@ -1711,7 +1711,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
         FieldInitializerValidatorCCC Validator(RT->getDecl());
         TypoCorrection Corrected = SemaRef.CorrectTypo(
             DeclarationNameInfo(FieldName, D->getFieldLoc()),
-            Sema::LookupMemberName, /*Scope=*/0, /*SS=*/0, &Validator,
+            Sema::LookupMemberName, /*Scope=*/0, /*SS=*/0, Validator,
             RT->getDecl());
         if (Corrected) {
           std::string CorrectedStr(
index 23ecb2509030db95d4f80203649a837fb6d96cc1..f2185157adb355c436b9caee98f9679f67918e72 100644 (file)
@@ -3536,7 +3536,7 @@ static void AddKeywordsToConsumer(Sema &SemaRef,
 TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
                                  Sema::LookupNameKind LookupKind,
                                  Scope *S, CXXScopeSpec *SS,
-                                 CorrectionCandidateCallback *CCC,
+                                 CorrectionCandidateCallback &CCC,
                                  DeclContext *MemberContext,
                                  bool EnteringContext,
                                  const ObjCObjectPointerType *OPT) {
@@ -3572,7 +3572,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
   // If a callback object returns true for an empty typo correction candidate,
   // assume it does not do any actual validation of the candidates.
   TypoCorrection EmptyCorrection;
-  bool ValidatingCallback = CCC && !CCC->ValidateCandidate(EmptyCorrection);
+  bool ValidatingCallback = !CCC.ValidateCandidate(EmptyCorrection);
 
   // Perform name lookup to find visible, similarly-named entities.
   bool IsUnqualifiedLookup = false;
@@ -3608,7 +3608,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
       // keyword case, we'll end up adding the keyword below.
       if (Cached->second) {
         if (!Cached->second.isKeyword() &&
-            (!CCC || CCC->ValidateCandidate(Cached->second)))
+            CCC.ValidateCandidate(Cached->second))
           Consumer.addCorrection(Cached->second);
       } else {
         // Only honor no-correction cache hits when a callback that will validate
@@ -3646,8 +3646,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
     }
   }
 
-  CorrectionCandidateCallback DefaultCCC;
-  AddKeywordsToConsumer(*this, Consumer, S, CCC ? *CCC : DefaultCCC);
+  AddKeywordsToConsumer(*this, Consumer, S, CCC);
 
   // If we haven't found anything, we're done.
   if (Consumer.empty()) {
@@ -3704,7 +3703,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
       if (I->second.isResolved()) {
         TypoCorrectionConsumer::result_iterator Prev = I;
         ++I;
-        if (CCC && !CCC->ValidateCandidate(Prev->second))
+        if (!CCC.ValidateCandidate(Prev->second))
           DI->second->erase(Prev);
         continue;
       }
@@ -3712,7 +3711,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
       // Perform name lookup on this name.
       IdentifierInfo *Name = I->second.getCorrectionAsIdentifierInfo();
       LookupPotentialTypoResult(*this, TmpRes, Name, S, SS, MemberContext,
-                                EnteringContext, CCC && CCC->IsObjCIvarLookup);
+                                EnteringContext, CCC.IsObjCIvarLookup);
 
       switch (TmpRes.getResultKind()) {
       case LookupResult::NotFound:
@@ -3741,7 +3740,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
              TRD != TRDEnd; ++TRD)
           I->second.addCorrectionDecl(*TRD);
         ++I;
-        if (CCC && !CCC->ValidateCandidate(Prev->second))
+        if (!CCC.ValidateCandidate(Prev->second))
           DI->second->erase(Prev);
         break;
       }
@@ -3750,7 +3749,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
         TypoCorrectionConsumer::result_iterator Prev = I;
         I->second.setCorrectionDecl(TmpRes.getAsSingle<NamedDecl>());
         ++I;
-        if (CCC && !CCC->ValidateCandidate(Prev->second))
+        if (!CCC.ValidateCandidate(Prev->second))
           DI->second->erase(Prev);
         break;
       }
@@ -3868,7 +3867,7 @@ TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
            // WantObjCSuper is only true for CTC_ObjCMessageReceiver and for
            // some instances of CTC_Unknown, while WantRemainingKeywords is true
            // for CTC_Unknown but not for CTC_ObjCMessageReceiver.
-           && CCC && CCC->WantObjCSuper && !CCC->WantRemainingKeywords
+           && CCC.WantObjCSuper && !CCC.WantRemainingKeywords
            && BestResults["super"].isKeyword()) {
     // Prefer 'super' when we're completing in a message-receiver
     // context.
index 66d7f1a23cceeb2c9c9cd9ad5a94ace733a4c2c2..76663a2d1217d53911258a9098de79de75ae0932 100644 (file)
@@ -310,7 +310,7 @@ void Sema::LookupTemplateName(LookupResult &Found,
     FilterCCC.WantCXXNamedCasts = true;
     if (TypoCorrection Corrected = CorrectTypo(Found.getLookupNameInfo(),
                                                Found.getLookupKind(), S, &SS,
-                                               &FilterCCC, LookupCtx)) {
+                                               FilterCCC, LookupCtx)) {
       Found.setLookupName(Corrected.getCorrection());
       if (Corrected.getCorrectionDecl())
         Found.addDecl(Corrected.getCorrectionDecl());
index 3dc60f8c7ae9d89f2eb782d77b8ae97c7337e55b..972f2236bd4f9004eb5c3122bd901d5c8a431823 100644 (file)
@@ -753,7 +753,7 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S,
   case LookupResult::NotFoundInCurrentInstantiation:
     if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(),
                                                R.getLookupKind(), S, 0,
-                                               &Validator)) {
+                                               Validator)) {
       std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOptions()));
       ParameterPack = Corrected.getCorrectionDecl();
       Diag(NameLoc, diag::err_sizeof_pack_no_pack_name_suggest)