]> granicus.if.org Git - clang/commitdiff
[Sema][ObjC] Complete merging ObjC methods before checking their
authorAkira Hatanaka <ahatanaka@apple.com>
Thu, 12 Oct 2017 23:24:38 +0000 (23:24 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Thu, 12 Oct 2017 23:24:38 +0000 (23:24 +0000)
overriding methods.

This should fix test case Analysis/retain-release.m that was failing on
the reverse iteration bot:

http://lab.llvm.org:8011/builders/reverse-iteration

The test used to fail because the loop in CheckObjCMethodOverrides would
merge attribute ns_returns_retained on methods while checking whether
the overriding methods were compatible. Since OverrideSearch::Overridden
is a SmallPtrSet and the order in which the elements of the set are
visited is non-deterministic, the test would fail when method 'clone' of
the protocol 'F18P' was visited before F18(Cat)'s method 'clone' was
visited.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315639 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclObjC.cpp

index c2d480c34ff2424374ac794150273257afb7805d..8f93d5c04f0c0e189f015057e75a4fb7825cbd29 100644 (file)
@@ -3580,8 +3580,6 @@ void Sema::mergeObjCMethodDecls(ObjCMethodDecl *newMethod,
          ni = newMethod->param_begin(), ne = newMethod->param_end();
        ni != ne && oi != oe; ++ni, ++oi)
     mergeParamDeclAttributes(*ni, *oi, *this);
-
-  CheckObjCMethodOverride(newMethod, oldMethod);
 }
 
 static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl* Old) {
index 5ab9d80c00b0a712964d46bc16fc0b07f0e041bb..104b2dfc9964a35df6e96401a1ba8c4fb1448404 100644 (file)
@@ -4223,6 +4223,10 @@ void Sema::CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod,
 
     // Then merge the declarations.
     mergeObjCMethodDecls(ObjCMethod, overridden);
+  }
+
+  for (ObjCMethodDecl *overridden : overrides) {
+    CheckObjCMethodOverride(ObjCMethod, overridden);
 
     if (ObjCMethod->isImplicit() && overridden->isImplicit())
       continue; // Conflicting properties are detected elsewhere.