[LLVMdev] what are those *Ref used for

Frédéric Riss friss at apple.com
Fri Feb 20 13:42:59 PST 2015


> On Feb 20, 2015, at 10:09 AM, Hui Zhang <wayne.huizhang at gmail.com> wrote:
> 
> Hello,
> 
> I'm a little confused about the DIScopeRef ,or other names end with Ref...Why and when shall we use them ?
> 
> Like StringRef, it has a function str() to change it to normal std::string, but DIScopeRef, its full definition is: 
> typedef DIRef<DIScope> <http://llvm.org/docs/doxygen/html/classllvm_1_1DIRef.html> DIScopeRef <http://llvm.org/docs/doxygen/html/namespacellvm.html#ad3fed63164a27d11963083c621293298>
> DIRef: Represents reference to a DIDescriptor <http://llvm.org/docs/doxygen/html/classllvm_1_1DIDescriptor.html>. abstracts over direct and identifier-based metadata references. 
> 
> ​Therefore, when I get a DIScopeRef dsf, shall I just treat it just like DIScope ? means I can directly call dsf.func(), where func() represents all the member functions of DIScope, right ??

First of all, DIScopeRef has nothing to do with StringRef. It’s not clear from you question if you want a general answer regarding the latter. For the DIScopeRef part:

No, you cannot call DIScope methods on a DIScopeRef. DIRef<>s are used to handle uniquing of some DebugInfo IR constructs. The ‘real’ DIScope that’s hidden behind a DIScopeRef can be retrieved using the resolve() method. You can look in DwarfDebug.cpp for places where this is done.

It would be easier to help you if you stated what you try to achieve. 

Fred

> Thanks​
> 
> -- 
> Best regards
> 
> 
> Hui Zhang
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150220/e2ac2922/attachment.html>


More information about the llvm-dev mailing list