Skip to content

Commit

Permalink
[Sema][ObjC] Use SmallSetVector to fix a failing test on the reverse
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ahatanaka committed Feb 6, 2018
1 parent cd07a3e commit 4c687f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions clang/lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4133,7 +4133,7 @@ class OverrideSearch {
public:
Sema &S;
ObjCMethodDecl *Method;
llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
llvm::SmallSetVector<ObjCMethodDecl*, 4> Overridden;
bool Recursive;

public:
Expand Down Expand Up @@ -4170,7 +4170,7 @@ class OverrideSearch {
}
}

typedef llvm::SmallPtrSetImpl<ObjCMethodDecl*>::iterator iterator;
typedef decltype(Overridden)::iterator iterator;
iterator begin() const { return Overridden.begin(); }
iterator end() const { return Overridden.end(); }

Expand Down Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions clang/test/SemaObjC/arc-decls.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,25 @@ @interface SomeClassOwnedByController ()

@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

0 comments on commit 4c687f3

Please sign in to comment.