本文整理汇总了C++中GlobalVariable::hasExternalLinkage方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalVariable::hasExternalLinkage方法的具体用法?C++ GlobalVariable::hasExternalLinkage怎么用?C++ GlobalVariable::hasExternalLinkage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalVariable
的用法示例。
在下文中一共展示了GlobalVariable::hasExternalLinkage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnModule
bool RegisterGlobals::runOnModule(Module &M) {
TD = &getAnalysis<TargetData>();
VoidTy = Type::getVoidTy(M.getContext());
VoidPtrTy = Type::getInt8PtrTy(M.getContext());
SizeTy = IntegerType::getInt64Ty(M.getContext());
// Create the function prototype
M.getOrInsertFunction("__pool_register_global", VoidTy, VoidPtrTy, SizeTy,
NULL);
RegisterGlobalPoolFunction = M.getFunction("__pool_register_global");
// Create the function that will contain the registration calls
createRegistrationFunction(M);
Module::global_iterator GI = M.global_begin(), GE = M.global_end();
for ( ; GI != GE; ++GI) {
GlobalVariable *GV = GI;
// Skip globals without a size
if (!GV->getType()->getElementType()->isSized())
continue;
// Optionally avoid registering globals with uncertain size.
if (!RegUncertain) {
// Linking can change the size of declarations
if (GV->isDeclaration())
continue;
// Linking can't change the size of defined globals with eternal linkage.
// Linking can't change the size of globals with local linkage.
if (!GV->hasExternalLinkage() && !GV->hasLocalLinkage())
continue;
}
// Thread-local globals would have to be registered for each thread.
// FIXME: add support for thread-local globals
if (GV->isThreadLocal())
continue;
registerGlobal(GV);
}
return true;
}