Patch to fix a warning which exposed a bug in building
a qualified objective-c pointer type. Fixes radar 7638810. (Also removes a FIXME). llvm-svn: 96003
This commit is contained in:
parent
363f847ec6
commit
dc68f9539c
|
@ -27,6 +27,7 @@
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/FoldingSet.h"
|
#include "llvm/ADT/FoldingSet.h"
|
||||||
#include "llvm/ADT/OwningPtr.h"
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -890,7 +891,7 @@ public:
|
||||||
unsigned CountSynthesizedIvars(const ObjCInterfaceDecl *OI);
|
unsigned CountSynthesizedIvars(const ObjCInterfaceDecl *OI);
|
||||||
unsigned CountProtocolSynthesizedIvars(const ObjCProtocolDecl *PD);
|
unsigned CountProtocolSynthesizedIvars(const ObjCProtocolDecl *PD);
|
||||||
void CollectInheritedProtocols(const Decl *CDecl,
|
void CollectInheritedProtocols(const Decl *CDecl,
|
||||||
llvm::SmallVectorImpl<ObjCProtocolDecl*> &Protocols);
|
llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols);
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Type Operators
|
// Type Operators
|
||||||
|
|
|
@ -917,12 +917,12 @@ void ASTContext::CollectSynthesizedIvars(const ObjCInterfaceDecl *OI,
|
||||||
/// CollectInheritedProtocols - Collect all protocols in current class and
|
/// CollectInheritedProtocols - Collect all protocols in current class and
|
||||||
/// those inherited by it.
|
/// those inherited by it.
|
||||||
void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
|
void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
|
||||||
llvm::SmallVectorImpl<ObjCProtocolDecl*> &Protocols) {
|
llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols) {
|
||||||
if (const ObjCInterfaceDecl *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
|
if (const ObjCInterfaceDecl *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
|
||||||
for (ObjCInterfaceDecl::protocol_iterator P = OI->protocol_begin(),
|
for (ObjCInterfaceDecl::protocol_iterator P = OI->protocol_begin(),
|
||||||
PE = OI->protocol_end(); P != PE; ++P) {
|
PE = OI->protocol_end(); P != PE; ++P) {
|
||||||
ObjCProtocolDecl *Proto = (*P);
|
ObjCProtocolDecl *Proto = (*P);
|
||||||
Protocols.push_back(Proto);
|
Protocols.insert(Proto);
|
||||||
for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(),
|
for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(),
|
||||||
PE = Proto->protocol_end(); P != PE; ++P)
|
PE = Proto->protocol_end(); P != PE; ++P)
|
||||||
CollectInheritedProtocols(*P, Protocols);
|
CollectInheritedProtocols(*P, Protocols);
|
||||||
|
@ -943,7 +943,7 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
|
||||||
for (ObjCInterfaceDecl::protocol_iterator P = OC->protocol_begin(),
|
for (ObjCInterfaceDecl::protocol_iterator P = OC->protocol_begin(),
|
||||||
PE = OC->protocol_end(); P != PE; ++P) {
|
PE = OC->protocol_end(); P != PE; ++P) {
|
||||||
ObjCProtocolDecl *Proto = (*P);
|
ObjCProtocolDecl *Proto = (*P);
|
||||||
Protocols.push_back(Proto);
|
Protocols.insert(Proto);
|
||||||
for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(),
|
for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(),
|
||||||
PE = Proto->protocol_end(); P != PE; ++P)
|
PE = Proto->protocol_end(); P != PE; ++P)
|
||||||
CollectInheritedProtocols(*P, Protocols);
|
CollectInheritedProtocols(*P, Protocols);
|
||||||
|
@ -954,7 +954,7 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
|
||||||
for (ObjCProtocolDecl::protocol_iterator P = OP->protocol_begin(),
|
for (ObjCProtocolDecl::protocol_iterator P = OP->protocol_begin(),
|
||||||
PE = OP->protocol_end(); P != PE; ++P) {
|
PE = OP->protocol_end(); P != PE; ++P) {
|
||||||
ObjCProtocolDecl *Proto = (*P);
|
ObjCProtocolDecl *Proto = (*P);
|
||||||
Protocols.push_back(Proto);
|
Protocols.insert(Proto);
|
||||||
for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(),
|
for (ObjCProtocolDecl::protocol_iterator P = Proto->protocol_begin(),
|
||||||
PE = Proto->protocol_end(); P != PE; ++P)
|
PE = Proto->protocol_end(); P != PE; ++P)
|
||||||
CollectInheritedProtocols(*P, Protocols);
|
CollectInheritedProtocols(*P, Protocols);
|
||||||
|
@ -4188,8 +4188,8 @@ void getIntersectionOfProtocols(ASTContext &Context,
|
||||||
if (LHSNumProtocols > 0)
|
if (LHSNumProtocols > 0)
|
||||||
InheritedProtocolSet.insert(LHS->qual_begin(), LHS->qual_end());
|
InheritedProtocolSet.insert(LHS->qual_begin(), LHS->qual_end());
|
||||||
else {
|
else {
|
||||||
llvm::SmallVector<ObjCProtocolDecl *, 8> LHSInheritedProtocols;
|
llvm::SmallPtrSet<ObjCProtocolDecl *, 8> LHSInheritedProtocols;
|
||||||
Context.CollectInheritedProtocols(LHS->getDecl(), LHSInheritedProtocols);
|
Context.CollectInheritedProtocols(LHS->getDecl(), LHSInheritedProtocols);
|
||||||
InheritedProtocolSet.insert(LHSInheritedProtocols.begin(),
|
InheritedProtocolSet.insert(LHSInheritedProtocols.begin(),
|
||||||
LHSInheritedProtocols.end());
|
LHSInheritedProtocols.end());
|
||||||
}
|
}
|
||||||
|
@ -4202,13 +4202,13 @@ void getIntersectionOfProtocols(ASTContext &Context,
|
||||||
IntersectionOfProtocols.push_back(RHSProtocols[i]);
|
IntersectionOfProtocols.push_back(RHSProtocols[i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
llvm::SmallVector<ObjCProtocolDecl *, 8> RHSInheritedProtocols;
|
llvm::SmallPtrSet<ObjCProtocolDecl *, 8> RHSInheritedProtocols;
|
||||||
Context.CollectInheritedProtocols(RHS->getDecl(), RHSInheritedProtocols);
|
Context.CollectInheritedProtocols(RHS->getDecl(), RHSInheritedProtocols);
|
||||||
// FIXME. This may cause duplication of protocols in the list, but should
|
for (llvm::SmallPtrSet<ObjCProtocolDecl*,8>::iterator I =
|
||||||
// be harmless.
|
RHSInheritedProtocols.begin(),
|
||||||
for (unsigned i = 0, len = RHSInheritedProtocols.size(); i < len; ++i)
|
E = RHSInheritedProtocols.end(); I != E; ++I)
|
||||||
if (InheritedProtocolSet.count(RHSInheritedProtocols[i]))
|
if (InheritedProtocolSet.count((*I)))
|
||||||
IntersectionOfProtocols.push_back(RHSInheritedProtocols[i]);
|
IntersectionOfProtocols.push_back((*I));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||||
|
// radar 7638810
|
||||||
|
|
||||||
|
@protocol NSObject @end
|
||||||
|
|
||||||
|
@interface NSObject <NSObject> @end
|
||||||
|
|
||||||
|
@interface UIResponder : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIResponder
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIView : UIResponder
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIWebTiledView : UIView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIWebTiledView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIWebDocumentView : UIWebTiledView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIWebDocumentView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIWebBrowserView : UIWebDocumentView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIWebBrowserView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIPDFView : UIView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIPDFView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface UIWebPDFView : UIPDFView
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation UIWebPDFView
|
||||||
|
@end
|
||||||
|
|
||||||
|
UIWebPDFView *getView()
|
||||||
|
{
|
||||||
|
UIWebBrowserView *browserView;
|
||||||
|
UIWebPDFView *pdfView;
|
||||||
|
return pdfView ? pdfView : browserView; // expected-warning {{incompatible pointer types returning 'UIView<NSObject> *', expected 'UIWebPDFView *'}}
|
||||||
|
}
|
Loading…
Reference in New Issue