refactor CheckForwardProtocolDeclarationForCircularDependency returns

'true' on detecting protocol cycles. No functionality change.

llvm-svn: 131297
This commit is contained in:
Fariborz Jahanian 2011-05-13 18:02:08 +00:00
parent 3e71464d50
commit 7d62273c87
2 changed files with 13 additions and 11 deletions

View File

@ -4760,11 +4760,10 @@ public:
IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *AliasName, SourceLocation AliasLocation,
IdentifierInfo *ClassName, SourceLocation ClassLocation); IdentifierInfo *ClassName, SourceLocation ClassLocation);
void CheckForwardProtocolDeclarationForCircularDependency( bool CheckForwardProtocolDeclarationForCircularDependency(
IdentifierInfo *PName, IdentifierInfo *PName,
SourceLocation &PLoc, SourceLocation PrevLoc, SourceLocation &PLoc, SourceLocation PrevLoc,
const ObjCList<ObjCProtocolDecl> &PList, const ObjCList<ObjCProtocolDecl> &PList);
bool &err);
Decl *ActOnStartProtocolInterface( Decl *ActOnStartProtocolInterface(
SourceLocation AtProtoInterfaceLoc, SourceLocation AtProtoInterfaceLoc,

View File

@ -272,24 +272,27 @@ Decl *Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
return AliasDecl; return AliasDecl;
} }
void Sema::CheckForwardProtocolDeclarationForCircularDependency( bool Sema::CheckForwardProtocolDeclarationForCircularDependency(
IdentifierInfo *PName, IdentifierInfo *PName,
SourceLocation &Ploc, SourceLocation PrevLoc, SourceLocation &Ploc, SourceLocation PrevLoc,
const ObjCList<ObjCProtocolDecl> &PList, bool &err) { const ObjCList<ObjCProtocolDecl> &PList) {
bool res = false;
for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(), for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(),
E = PList.end(); I != E; ++I) { E = PList.end(); I != E; ++I) {
if (ObjCProtocolDecl *PDecl = LookupProtocol((*I)->getIdentifier(), if (ObjCProtocolDecl *PDecl = LookupProtocol((*I)->getIdentifier(),
Ploc)) { Ploc)) {
if (PDecl->getIdentifier() == PName) { if (PDecl->getIdentifier() == PName) {
Diag(Ploc, diag::err_protocol_has_circular_dependency); Diag(Ploc, diag::err_protocol_has_circular_dependency);
Diag(PrevLoc, diag::note_previous_definition); Diag(PrevLoc, diag::note_previous_definition);
err = true; res = true;
} }
CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc, if (CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc,
PDecl->getLocation(), PDecl->getReferencedProtocols(), err); PDecl->getLocation(), PDecl->getReferencedProtocols()))
res = true;
} }
} }
return res;
} }
Decl * Decl *
@ -316,8 +319,8 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
} }
ObjCList<ObjCProtocolDecl> PList; ObjCList<ObjCProtocolDecl> PList;
PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context); PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
CheckForwardProtocolDeclarationForCircularDependency( err = CheckForwardProtocolDeclarationForCircularDependency(
ProtocolName, ProtocolLoc, PDecl->getLocation(), PList, err); ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
// Make sure the cached decl gets a valid start location. // Make sure the cached decl gets a valid start location.
PDecl->setLocation(AtProtoInterfaceLoc); PDecl->setLocation(AtProtoInterfaceLoc);