what are those *Ref used for

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 ??

Thanks​

Hi, all

Is there anyone who can address this question for me ? really appreciate …

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