本文整理汇总了C++中module::global_iterator::eraseFromParent方法的典型用法代码示例。如果您正苦于以下问题:C++ global_iterator::eraseFromParent方法的具体用法?C++ global_iterator::eraseFromParent怎么用?C++ global_iterator::eraseFromParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::global_iterator
的用法示例。
在下文中一共展示了global_iterator::eraseFromParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnModule
bool StripExternals::runOnModule(Module &M) {
bool Changed = false;
for (Module::iterator I = M.begin(); I != M.end(); ) {
if (I->hasAvailableExternallyLinkage()) {
assert(!I->isDeclaration()&&"Declarations can't be available_externally");
Changed = true;
++NumFunctions;
if (I->use_empty()) {
DEBUG(errs() << "Deleting function: " << *I);
Module::iterator todelete = I;
++I;
todelete->eraseFromParent();
continue;
} else {
I->deleteBody();
DEBUG(errs() << "Deleted function body: " << *I);
}
}
++I;
}
for (Module::global_iterator I = M.global_begin();
I != M.global_end(); ) {
if (I->hasAvailableExternallyLinkage()) {
assert(!I->isDeclaration()&&"Declarations can't be available_externally");
Changed = true;
++NumVariables;
if (I->use_empty()) {
DEBUG(errs() << "Deleting global: " << *I);
Module::global_iterator todelete = I;
++I;
todelete->eraseFromParent();
continue;
} else {
I->setInitializer(0);
I->setLinkage(GlobalValue::ExternalLinkage);
DEBUG(errs() << "Deleted initializer: " << *I);
}
}
++I;
}
return Changed;
}