我需要从现有的DIVariable
创建一个MDNode
。
根据documentation,DIVariable
继承自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 {
我尝试进一步升级并从DINode
创建一个MDNode
以查看是否有效,这给出了类似的错误:
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 {
那个错误对我来说毫无意义。从另一个继承的类如何不隐式转换为它?
为将来搜索的人找到了答案。
[In r234255许多隐式副本构造函数已被删除,而偏向cast<>, isa<>, and dyn_cast<>。