]> granicus.if.org Git - clang/commitdiff
[Sema][ObjC] Use SmallSetVector to fix a failing test on the reverse
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 6 Feb 2018 23:44:40 +0000 (23:44 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 6 Feb 2018 23:44:40 +0000 (23:44 +0000)
iteration bot.

This commit reverts r315639, which was causing clang to print
diagnostics that weren't printed before. Instead, it declares
OverrideSearch::Overridden as a SmallSetVector to fix the
non-deterministic behavior r315639 was trying to fix.

rdar://problem/36445528

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

lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/arc-decls.m

index c3975f9f62d9cba9c61754ea706cfb91d2e54433..b70e2306ca2d555ab0efa69802284f67c6cb4bf3 100644 (file)
@@ -3623,6 +3623,8 @@ 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 d44b5f357df1ad76abd7e2d63d2d71dcc303b7c8..c17fde497ae7718a6f79663f6f69a8739fadc277 100644 (file)
@@ -4133,7 +4133,7 @@ class OverrideSearch {
 public:
   Sema &S;
   ObjCMethodDecl *Method;
-  llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
+  llvm::SmallSetVector<ObjCMethodDecl*, 4> Overridden;
   bool Recursive;
 
 public:
@@ -4170,7 +4170,7 @@ public:
     }
   }
 
-  typedef llvm::SmallPtrSetImpl<ObjCMethodDecl*>::iterator iterator;
+  typedef decltype(Overridden)::iterator iterator;
   iterator begin() const { return Overridden.begin(); }
   iterator end() const { return Overridden.end(); }
 
@@ -4338,10 +4338,6 @@ 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.
index c1c319d95e3cf02d0f7e8ed5ce0c2a5dcf66eee8..15fb78be0899d0b06a0868ff4936c2f4003ca78f 100644 (file)
@@ -154,3 +154,25 @@ struct __attribute__((objc_ownership(none))) S2 {}; // expected-error {{'objc_ow
 
 @property (readwrite, weak) ControllerClass *weak_controller;
 @end
+
+@interface I3
+@end
+
+@interface D3 : I3
+@end
+
+@interface D3 (Cat1)
+- (id)method;
+@end
+
+@interface I3 (Cat2)
+// FIXME: clang should diagnose mismatch between methods in D3(Cat1) and
+//        I3(Cat2).
+- (id)method __attribute__((ns_returns_retained));
+@end
+
+@implementation D3
+- (id)method {
+  return (id)0;
+}
+@end