LLVM MDNode继承

LLVM MDNode inheritence

我需要从现有的 MDNode 创建一个 DIVariable

根据 documentationDIVariable 继承自 MDNode。但是直接尝试创建会出现错误:

error: no matching constructor for initialization of 'llvm::DIVariable'
                  DIVariable newDIVar(*newMDNode);
                             ^        ~~~~~~~~~~
/root/llvm-7.0.0/include/llvm/IR/DebugInfoMetadata.h:2193:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'llvm::MDNode' to 'const llvm::DIVariable' for 1st
      argument
class DIVariable : public DINode {

我尝试更进一步并从 MDNode 创建一个 DINode 以查看它是否有效,这给出了类似的错误:

error: no matching constructor for initialization of 'llvm::DINode'
                  DINode newDINode(*newMDNode);
                         ^         ~~~~~~~~~~
/root/llvm-7.0.0/include/llvm/IR/DebugInfoMetadata.h:155:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'llvm::MDNode' to 'const llvm::DINode' for 1st
      argument
class DINode : public MDNode {

那个错误对我来说没有意义。从另一个继承的 class 如何不隐式转换为它?

为以后搜索的任何人找到了答案。

In r234255 many implicit copy constructors were removed in favor of cast<>, isa<>, and dyn_cast<>.