如何处理 LLVM metadata.h 中的更改

voi*_*urn 5 c++ metadata llvm llvm-ir

在 LLVM 3.6 版中,他们对元数据类进行了大量更改,并将元数据与值分开。所以我之前基于 3.5 版本的代码不再起作用了。我在升级代码时遇到困难。任何人都可以帮忙。

例如:以前的代码:

MDNode *record;
Value *undVal = record->getOperand(1);
Type *type_hint = undVal->getType();
Run Code Online (Sandbox Code Playgroud)

有谁知道如何升级此代码以使其与 3.6 兼容?

我试过这个:

MDNode *record;
const MDOperand &undVal = record->getOperand(1);
Type *type_hint = undVal->getType();
Run Code Online (Sandbox Code Playgroud)

但它不起作用。结果编译错误说

“getType”:不是“llvm::Metadata”的成员

任何帮助表示赞赏。

小智 1

您是否尝试过 dyn_cast<>,如下所示:

Value* undval = dyn_cast<Value>(record->getoperand(1));
Type* type_hint;
if(undval) type_hint = undVal->hetType();
Run Code Online (Sandbox Code Playgroud)