[llvm-dev] Upgrading LLVM API versions, trouble with DIVariable

Trevor Martin via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 8 11:23:04 PDT 2019


I am working on upgrading LLVM libraries from 3.0 to 7.0.0 for a project to
be compatible with an outside project.

I've made good progress but am running into a wall for all things related
to DIVariables and there creation from existing Metadata objects.

Specifically I've run into 3 issues;

(1)I am trying to create a DIType from the Type of an existing DIVariable
using getType().

foo (DIVariable& oldDIVar){

    const DIType oldDIType = oldDIVar.getType();

According to the llvm documentation, DIVariable::getType should return a
DIType*. But I get an error message:

error: no viable conversion from 'llvm::DITypeRef' (aka
'TypedDINodeRef<llvm::DIType>') to 'const llvm::DIType *'
  const DIType *oldDIType = oldDIVar.getType();
                ^           ~~~~~~~~~~~~~~~~~~

I've messed around with dereferencing the oldDIVar variable, which points
to the underlying Metadata of it. I would assume that attempting to create
a DIType from pure metadata would be fine, since it inherits from the
metadata class. But I always get the error:

 error: no viable conversion from 'llvm::Metadata' to 'llvm::DIType'
  DIType oldDIType = *oldDIVar.getType();
         ^           ~~~~~~~~~~~~~~~~~~~
/root/llvm-7.0.0/include/llvm/IR/DebugInfoMetadata.h:630:7: note: candidate
constructor (the implicit copy constructor) not viable: cannot bind base
class object of type 'llvm::Metadata' to derived class
      reference 'const llvm::DIType &' for 1st argument
class DIType : public DIScope {

Am I missing something about inheritance that prevents this?

(2)One of the other errors is similar;

  Unable to convert from MDNode to DIVariable

(3)The final one is strange to me. Once again trying to make a DIVariable
from and oldDIVar,
this time calling DbgVariables::getVariables(). I try to call it as such;

DIVariable oldDIVar(*(oldDeclare->getVariable());

But that seems to give an error due to an implicitly deleted copy
constructor, which completely baffles me.

error: call to implicitly-deleted copy constructor of 'llvm::DIVariable'
                  DIVariable oldDIVar(*(oldDeclare->getVariable()));

If anyone could provide insight into why creating DIVariables and DITypes
is failing, and what the implicitly deleted copy constructor is being
caused by, I'd really appreciate it.

This is my first time using this mailing list, so apologies of I made a
mistake somewhere.


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

More information about the llvm-dev mailing list