forked from OSchip/llvm-project
Refactoring of code to issue warning on implemented
deprecated class and methods in objective-c. llvm-svn: 125573
This commit is contained in:
parent
4ab0852080
commit
d724a109cf
|
@ -24,6 +24,23 @@
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
|
static void DiagnoseObjCImplementedDeprecations(Sema &S,
|
||||||
|
NamedDecl *ND,
|
||||||
|
SourceLocation ImplLoc,
|
||||||
|
int select) {
|
||||||
|
|
||||||
|
unsigned DIAG = diag::warn_depercated_def;
|
||||||
|
if (S.Diags.getDiagnosticLevel(DIAG, ImplLoc)== Diagnostic::Ignored)
|
||||||
|
return;
|
||||||
|
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
|
/// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible
|
||||||
/// and user declared, in the method definition's AST.
|
/// and user declared, in the method definition's AST.
|
||||||
void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
|
void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
|
||||||
|
@ -66,19 +83,12 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
|
||||||
}
|
}
|
||||||
// Warn on implementating deprecated methods under
|
// Warn on implementating deprecated methods under
|
||||||
// -Wdeprecated-implementations flag.
|
// -Wdeprecated-implementations flag.
|
||||||
// FIXME. Refactor using common routine.
|
if (ObjCInterfaceDecl *IC = MDecl->getClassInterface())
|
||||||
unsigned DIAG = diag::warn_depercated_def;
|
|
||||||
if (Diags.getDiagnosticLevel(DIAG, MDecl->getLocation())
|
|
||||||
!= Diagnostic::Ignored)
|
|
||||||
if (ObjCInterfaceDecl *IC = MDecl->getClassInterface()) {
|
|
||||||
if (ObjCMethodDecl *IMD =
|
if (ObjCMethodDecl *IMD =
|
||||||
IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()))
|
IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()))
|
||||||
if (NamedDecl *ND = dyn_cast<NamedDecl>(IMD))
|
DiagnoseObjCImplementedDeprecations(*this,
|
||||||
if (ND->getAttr<DeprecatedAttr>()) {
|
dyn_cast<NamedDecl>(IMD),
|
||||||
Diag(MDecl->getLocation(), DIAG) << 0;
|
MDecl->getLocation(), 0);
|
||||||
Diag(IMD->getLocation(), diag::note_method_declared_at);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Decl *Sema::
|
Decl *Sema::
|
||||||
|
@ -556,16 +566,9 @@ Decl *Sema::ActOnStartCategoryImplementation(
|
||||||
CatIDecl->setImplementation(CDecl);
|
CatIDecl->setImplementation(CDecl);
|
||||||
// Warn on implementating category of deprecated class under
|
// Warn on implementating category of deprecated class under
|
||||||
// -Wdeprecated-implementations flag.
|
// -Wdeprecated-implementations flag.
|
||||||
// FIXME. Refactor using common routine.
|
DiagnoseObjCImplementedDeprecations(*this,
|
||||||
unsigned DIAG = diag::warn_depercated_def;
|
dyn_cast<NamedDecl>(IDecl),
|
||||||
if (Diags.getDiagnosticLevel(DIAG, CDecl->getLocation())
|
CDecl->getLocation(), 2);
|
||||||
!= 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";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,15 +680,9 @@ Decl *Sema::ActOnStartClassImplementation(
|
||||||
PushOnScopeChains(IMPDecl, TUScope);
|
PushOnScopeChains(IMPDecl, TUScope);
|
||||||
// Warn on implementating deprecated class under
|
// Warn on implementating deprecated class under
|
||||||
// -Wdeprecated-implementations flag.
|
// -Wdeprecated-implementations flag.
|
||||||
// FIXME. Refactor using common routine.
|
DiagnoseObjCImplementedDeprecations(*this,
|
||||||
unsigned DIAG = diag::warn_depercated_def;
|
dyn_cast<NamedDecl>(IDecl),
|
||||||
if (Diags.getDiagnosticLevel(DIAG, IMPDecl->getLocation())
|
IMPDecl->getLocation(), 1);
|
||||||
!= 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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return IMPDecl;
|
return IMPDecl;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue