[cfe-commits] r125573 - /cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Chris Lattner clattner at apple.com
Tue Feb 15 15:38:29 PST 2011


On Feb 15, 2011, at 9:49 AM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Tue Feb 15 11:49:58 2011
> New Revision: 125573
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=125573&view=rev
> Log:
> Refactoring of code to issue warning on implemented
> deprecated class and methods in objective-c.

Nice! Some minor stuff:

> +  
> +  unsigned DIAG = diag::warn_depercated_def;

This isn't new to this patch, but 'depercated' is misspelled.

> +  if (S.Diags.getDiagnosticLevel(DIAG, ImplLoc)== Diagnostic::Ignored)
> +    return;

There's no need to check to see if the diagnostic is ignored here, it's more efficient to not do this in this case since the warning check is so simple.

-Chris

> +  if (ND && ND->getAttr<DeprecatedAttr>()) {
> +    S.Diag(ImplLoc, DIAG) << select;
> +    if (select == 0)
> +      S.Diag(ND->getLocation(), diag::note_method_declared_at);
> +    else
> +      S.Diag(ND->getLocation(), diag::note_previous_decl) << "class";
> +  }
> +}
> +
> /// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible
> /// and user declared, in the method definition's AST.
> void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
> @@ -66,19 +83,12 @@
>   }
>   // Warn on implementating deprecated methods under 
>   // -Wdeprecated-implementations flag.
> -  // FIXME. Refactor using common routine.
> -  unsigned DIAG = diag::warn_depercated_def;
> -  if (Diags.getDiagnosticLevel(DIAG, MDecl->getLocation())
> -      != Diagnostic::Ignored)
> -    if (ObjCInterfaceDecl *IC = MDecl->getClassInterface()) {
> -      if (ObjCMethodDecl *IMD = 
> +  if (ObjCInterfaceDecl *IC = MDecl->getClassInterface())
> +    if (ObjCMethodDecl *IMD = 
>           IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()))
> -        if (NamedDecl *ND = dyn_cast<NamedDecl>(IMD))
> -          if (ND->getAttr<DeprecatedAttr>()) {
> -            Diag(MDecl->getLocation(), DIAG) << 0;
> -            Diag(IMD->getLocation(), diag::note_method_declared_at);
> -          }
> -    }
> +      DiagnoseObjCImplementedDeprecations(*this, 
> +                                          dyn_cast<NamedDecl>(IMD), 
> +                                          MDecl->getLocation(), 0);
> }
> 
> Decl *Sema::
> @@ -556,16 +566,9 @@
>       CatIDecl->setImplementation(CDecl);
>       // Warn on implementating category of deprecated class under 
>       // -Wdeprecated-implementations flag.
> -      // FIXME. Refactor using common routine.
> -      unsigned DIAG = diag::warn_depercated_def;
> -      if (Diags.getDiagnosticLevel(DIAG, CDecl->getLocation())
> -          != Diagnostic::Ignored)
> -        if (NamedDecl *ND = dyn_cast<NamedDecl>(IDecl))
> -          if (ND->getAttr<DeprecatedAttr>()) {
> -            Diag(CDecl->getLocation(), DIAG) << 2;
> -            Diag(IDecl->getLocation(), diag::note_previous_decl) << "class";
> -          }
> -
> +      DiagnoseObjCImplementedDeprecations(*this, 
> +                                          dyn_cast<NamedDecl>(IDecl), 
> +                                          CDecl->getLocation(), 2);
>     }
>   }
> 
> @@ -677,15 +680,9 @@
>     PushOnScopeChains(IMPDecl, TUScope);
>     // Warn on implementating deprecated class under 
>     // -Wdeprecated-implementations flag.
> -    // FIXME. Refactor using common routine.
> -    unsigned DIAG = diag::warn_depercated_def;
> -    if (Diags.getDiagnosticLevel(DIAG, IMPDecl->getLocation())
> -          != Diagnostic::Ignored)
> -      if (NamedDecl *ND = dyn_cast<NamedDecl>(IDecl))
> -        if (ND->getAttr<DeprecatedAttr>()) {
> -          Diag(IMPDecl->getLocation(), DIAG) << 1;
> -          Diag(IDecl->getLocation(), diag::note_previous_decl) << "class";
> -       }
> +    DiagnoseObjCImplementedDeprecations(*this, 
> +                                        dyn_cast<NamedDecl>(IDecl), 
> +                                        IMPDecl->getLocation(), 1);
>   }
>   return IMPDecl;
> }
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list