[cfe-commits] r131254 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp

Douglas Gregor dgregor at apple.com
Thu May 12 18:09:04 PDT 2011


On May 12, 2011, at 3:04 PM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Thu May 12 17:04:39 2011
> New Revision: 131254
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=131254&view=rev
> Log:
> After issuing diagnostics on circular protocol list,
> don't build circular AST in protocol's protocol list 
> when user code has introduced it. Indexer and other   
> clients may crash. // rdar://9221614

Excellent, thanks!

> Modified:
>    cfe/trunk/include/clang/Sema/Sema.h
>    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=131254&r1=131253&r2=131254&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu May 12 17:04:39 2011
> @@ -4739,7 +4739,8 @@
>   void CheckForwardProtocolDeclarationForCircularDependency(
>     IdentifierInfo *PName,
>     SourceLocation &PLoc, SourceLocation PrevLoc,
> -    const ObjCList<ObjCProtocolDecl> &PList);
> +    const ObjCList<ObjCProtocolDecl> &PList,
> +    bool &err);

Why not just return true on error, as we commonly do in Clang? Does the reference variable have any benefit?

>   Decl *ActOnStartProtocolInterface(
>                     SourceLocation AtProtoInterfaceLoc,
> 
> Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=131254&r1=131253&r2=131254&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu May 12 17:04:39 2011
> @@ -275,7 +275,7 @@
> void Sema::CheckForwardProtocolDeclarationForCircularDependency(
>   IdentifierInfo *PName,
>   SourceLocation &Ploc, SourceLocation PrevLoc,
> -  const ObjCList<ObjCProtocolDecl> &PList) {
> +  const ObjCList<ObjCProtocolDecl> &PList, bool &err) {
>   for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(),
>        E = PList.end(); I != E; ++I) {
> 
> @@ -284,9 +284,10 @@
>       if (PDecl->getIdentifier() == PName) {
>         Diag(Ploc, diag::err_protocol_has_circular_dependency);
>         Diag(PrevLoc, diag::note_previous_definition);
> +        err = true;
>       }
>       CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc,
> -        PDecl->getLocation(), PDecl->getReferencedProtocols());
> +        PDecl->getLocation(), PDecl->getReferencedProtocols(), err);
>     }
>   }
> }
> @@ -300,6 +301,7 @@
>                                   const SourceLocation *ProtoLocs,
>                                   SourceLocation EndProtoLoc,
>                                   AttributeList *AttrList) {
> +  bool err = false;
>   // FIXME: Deal with AttrList.
>   assert(ProtocolName && "Missing protocol identifier");
>   ObjCProtocolDecl *PDecl = LookupProtocol(ProtocolName, ProtocolLoc);
> @@ -315,7 +317,7 @@
>     ObjCList<ObjCProtocolDecl> PList;
>     PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
>     CheckForwardProtocolDeclarationForCircularDependency(
> -      ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
> +      ProtocolName, ProtocolLoc, PDecl->getLocation(), PList, err);
> 
>     // Make sure the cached decl gets a valid start location.
>     PDecl->setLocation(AtProtoInterfaceLoc);
> @@ -331,7 +333,7 @@
>   }
>   if (AttrList)
>     ProcessDeclAttributeList(TUScope, PDecl, AttrList);
> -  if (NumProtoRefs) {
> +  if (!err && NumProtoRefs ) {
>     /// Check then save referenced protocols.
>     PDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,
>                            ProtoLocs, Context);
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list