aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-22 02:45:48 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-22 02:45:48 +0000
commit6c2c250db1e2d0138bbfaadbbec3118db7e8a8c9 (patch)
treea67ea5cf0a0af1a46b95c3b6166de4613a64b23a /lib/Sema/SemaDecl.cpp
parentdb8264e4c5ffd7af6fbad4ca4306bd382bb02691 (diff)
In Objective-C, pull arbitrary attributes from overridden
methods, including indirectly overridden methods like those declared in protocols and categories. There are mismatches that we would like to diagnose but aren't yet, but this is fine for now. I looked at approaches that avoided doing this lookup unless we needed it, but the infer-related-result-type checks were doing it anyway, so I left it with the same fast-path check for no previous declartions of that selector. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135743 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 9d91a48bdc..22a9f37bf1 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1456,7 +1456,7 @@ DeclHasAttr(const Decl *D, const Attr *A) {
/// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
static void mergeDeclAttributes(Decl *newDecl, const Decl *oldDecl,
- ASTContext &C) {
+ ASTContext &C, bool mergeDeprecation = true) {
if (!oldDecl->hasAttrs())
return;
@@ -1469,6 +1469,11 @@ static void mergeDeclAttributes(Decl *newDecl, const Decl *oldDecl,
for (specific_attr_iterator<InheritableAttr>
i = oldDecl->specific_attr_begin<InheritableAttr>(),
e = oldDecl->specific_attr_end<InheritableAttr>(); i != e; ++i) {
+ // Ignore deprecated and unavailable attributes if requested.
+ if (!mergeDeprecation &&
+ (isa<DeprecatedAttr>(*i) || isa<UnavailableAttr>(*i)))
+ continue;
+
if (!DeclHasAttr(newDecl, *i)) {
InheritableAttr *newAttr = cast<InheritableAttr>((*i)->clone(C));
newAttr->setInherited(true);
@@ -1949,15 +1954,19 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) {
void Sema::mergeObjCMethodDecls(ObjCMethodDecl *newMethod,
const ObjCMethodDecl *oldMethod) {
+ // We don't want to merge unavailable and deprecated attributes
+ // except from interface to implementation.
+ bool mergeDeprecation = isa<ObjCImplDecl>(newMethod->getDeclContext());
+
// Merge the attributes.
- mergeDeclAttributes(newMethod, oldMethod, Context);
+ mergeDeclAttributes(newMethod, oldMethod, Context, mergeDeprecation);
// Merge attributes from the parameters.
for (ObjCMethodDecl::param_iterator oi = oldMethod->param_begin(),
ni = newMethod->param_begin(), ne = newMethod->param_end();
ni != ne; ++ni, ++oi)
mergeParamDeclAttributes(*ni, *oi, Context);
-
+
CheckObjCMethodOverride(newMethod, oldMethod, true);
}