2016-03-07 52 views

回答

2

如果您有GetElementPtrInst* GEP,则可以使用GEP->getOperand(i)(操作数0是指针,其余操作数是索引)访问索引。为了得到值5,就可以检查该指数是一个ConstantInt如果是这样得到它的价值,像这样:

if (ConstantInt *CI = dyn_cast<ConstantInt>(GEP->getOperand(1)) { 
    uint64_t Idx = CI->getZExtValue(); 
}