Skip to content

Commit 4c687f3

Browse files
committed
[Sema][ObjC] Use SmallSetVector to fix a failing test on the reverse
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 llvm-svn: 324425
1 parent cd07a3e commit 4c687f3

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,6 +3623,8 @@ void Sema::mergeObjCMethodDecls(ObjCMethodDecl *newMethod,
36233623
ni = newMethod->param_begin(), ne = newMethod->param_end();
36243624
ni != ne && oi != oe; ++ni, ++oi)
36253625
mergeParamDeclAttributes(*ni, *oi, *this);
3626+
3627+
CheckObjCMethodOverride(newMethod, oldMethod);
36263628
}
36273629

36283630
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl* Old) {

clang/lib/Sema/SemaDeclObjC.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4133,7 +4133,7 @@ class OverrideSearch {
41334133
public:
41344134
Sema &S;
41354135
ObjCMethodDecl *Method;
4136-
llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
4136+
llvm::SmallSetVector<ObjCMethodDecl*, 4> Overridden;
41374137
bool Recursive;
41384138

41394139
public:
@@ -4170,7 +4170,7 @@ class OverrideSearch {
41704170
}
41714171
}
41724172

4173-
typedef llvm::SmallPtrSetImpl<ObjCMethodDecl*>::iterator iterator;
4173+
typedef decltype(Overridden)::iterator iterator;
41744174
iterator begin() const { return Overridden.begin(); }
41754175
iterator end() const { return Overridden.end(); }
41764176

@@ -4338,10 +4338,6 @@ void Sema::CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod,
43384338

43394339
// Then merge the declarations.
43404340
mergeObjCMethodDecls(ObjCMethod, overridden);
4341-
}
4342-
4343-
for (ObjCMethodDecl *overridden : overrides) {
4344-
CheckObjCMethodOverride(ObjCMethod, overridden);
43454341

43464342
if (ObjCMethod->isImplicit() && overridden->isImplicit())
43474343
continue; // Conflicting properties are detected elsewhere.

clang/test/SemaObjC/arc-decls.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,25 @@ @interface SomeClassOwnedByController ()
154154

155155
@property (readwrite, weak) ControllerClass *weak_controller;
156156
@end
157+
158+
@interface I3
159+
@end
160+
161+
@interface D3 : I3
162+
@end
163+
164+
@interface D3 (Cat1)
165+
- (id)method;
166+
@end
167+
168+
@interface I3 (Cat2)
169+
// FIXME: clang should diagnose mismatch between methods in D3(Cat1) and
170+
// I3(Cat2).
171+
- (id)method __attribute__((ns_returns_retained));
172+
@end
173+
174+
@implementation D3
175+
- (id)method {
176+
return (id)0;
177+
}
178+
@end

0 commit comments

Comments
 (0)