summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-02-15 17:49:58 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-02-15 17:49:58 +0000
commitd724a109cf1981bb5c3d2f12769ca580dba91460 (patch)
tree85ad69b6d70a50ad09c6f621fc3bf76c7cc96e24
parent4ab085208023952ae571f934788ea4fd9eb98bb2 (diff)
downloadbcm5719-llvm-d724a109cf1981bb5c3d2f12769ca580dba91460.tar.gz
bcm5719-llvm-d724a109cf1981bb5c3d2f12769ca580dba91460.zip
Refactoring of code to issue warning on implemented
deprecated class and methods in objective-c. llvm-svn: 125573
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp59
1 files changed, 28 insertions, 31 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 3aeb50b032d..865f22aec53 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -24,6 +24,23 @@
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
/// and user declared, in the method definition's AST.
void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
@@ -66,19 +83,12 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
}
// 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 @@ Decl *Sema::ActOnStartCategoryImplementation(
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 @@ Decl *Sema::ActOnStartClassImplementation(
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;
}
OpenPOWER on IntegriCloud