使用llvm::dyn\u cast进行强制转换导致错误

使用llvm::dyn\u cast进行强制转换导致错误,llvm,Llvm,我试图反复使用store inst的操作数。我按照程序员手册来做,但我得到了错误 //x is store instruction pointing to [store i32 5, i32* %a, align 4] Value *op2 = x->getOperand(1); for (Value::use_iterator useItr=op2->use_begin(),useEnd=op2->use_end(); useItr!=useEnd;useItr++){

我试图反复使用store inst的操作数。我按照程序员手册来做,但我得到了错误

//x is store instruction pointing to [store i32 5, i32* %a, align 4]
Value *op2 = x->getOperand(1);
for (Value::use_iterator useItr=op2->use_begin(),useEnd=op2->use_end(); useItr!=useEnd;useItr++){
    if (Instruction *Inst = dyn_cast_or_null<Instruction>(*useItr))
        errs()<<"done";
}
//x是指向[store i32 5,i32*%a,align 4]的存储指令
值*op2=x->getOperator(1);
对于(Value::use_iterator useItr=op2->use_begin(),useEnd=op2->use_end();useItr!=useEnd;useItr++){
if(指令*Inst=dyn\U cast\U或\U null(*useItr))

errs()您的错误来自于取消引用
useItr
,而不是来自
dyn\u cast
。您的代码在我看来很好,因此我查看了
value\u use\u iterator
的实现,我能想到的唯一方法是如果值的使用之一是
NULL


但是,在合法模块中不能使用
NULL
。因此,我建议在代码之前在您的模块上运行,看看它是否能够发现问题-否则您必须自己仔细检查模块。

好吧,问题似乎出在最新的llvm代码上,因为我使用svn签出最新的代码.我终于获得了3.4稳定版,现在一切正常。

还有其他方法可以完成吗?