[cfe-dev] AST references

steve naroff snaroff at apple.com
Tue Oct 13 15:55:51 PDT 2009


Hi Kevin,

In the example below, Protocol references are resolved by the  
ObjCInterfaceDecl API (e.g. the iterator on ObjCInterfaceDecl should  
return the ObjCProtocolDecl for 'MyProtocol').

In the debug output below, $4 looks like a 'DeclContext' (which  
ObjCProtocolDecl inherits from indirectly).

Let me know if you need further assistance,

snaroff

On Oct 13, 2009, at 6:41 PM, Kevin Cathey wrote:

> I have the following file:
>
> @protocol MyProtocol
> - (void)someProtocolMethod;
> @end
>
> @interface MyBaseClass <MyProtocol> {
>     id myIvar;
> }
> @end
>
> When printing out the AST node for the @protocol declaration, I get:
> $4 = {
>   DeclKind = clang::Decl::ObjCProtocol,
>   ExternalLexicalStorage = false,
>   ExternalVisibleStorage = false,
>   LookupPtr = 0x0,
>   FirstDecl = 0x1033160c0,
>   LastDecl = 0x1033160c0
> }
>
> However, when I print out the AST node for <MyProtocol>, I get a  
> different value:
> $5 = {
>   <clang::Decl> = {
>     _vptr$Decl = 0x1016f80d0,
>     NextDeclInContext = 0x103316150,
>     DeclCtx = {
>       Val = {
>         Value = 4348516192
>       }
>     },
>     Loc = {
>       ID = 2
>     },
>     DeclKind = clang::Decl::ObjCProtocol,
>     InvalidDecl = 0,
>     HasAttrs = 0,
>     Implicit = false,
>     Used = false,
>     IdentifierNamespace = 16,
>     Access = 0
>   },
>   members of clang::NamedDecl:
>   Name = {
>     Ptr = 4353910984
>   }
> }
>
> I was under the impression that clang would resolve references. So  
> MyProtocol would be the same in both places. If not, how do I  
> resolve these references?
>
> Thanks.
>
> Kevin
>
> -------------------------------------------------
> Kevin Cathey
> Department of Computer Science - College of Engineering
> University of Illinois Urbana Champaign
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091013/664caebf/attachment.html>


More information about the cfe-dev mailing list