本文整理汇总了C++中LLGlobalVariable::setDLLStorageClass方法的典型用法代码示例。如果您正苦于以下问题:C++ LLGlobalVariable::setDLLStorageClass方法的具体用法?C++ LLGlobalVariable::setDLLStorageClass怎么用?C++ LLGlobalVariable::setDLLStorageClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLGlobalVariable
的用法示例。
在下文中一共展示了LLGlobalVariable::setDLLStorageClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void visit(VarDeclaration *decl) override {
IF_LOG Logger::println("VarDeclaration::codegen(): '%s'",
decl->toPrettyChars());
LOG_SCOPE;
if (decl->ir->isDefined()) {
return;
}
if (decl->type->ty == Terror) {
error(decl->loc, "had semantic errors when compiling");
decl->ir->setDefined();
return;
}
DtoResolveVariable(decl);
decl->ir->setDefined();
// just forward aliases
if (decl->aliassym) {
Logger::println("alias sym");
decl->toAlias()->accept(this);
return;
}
// global variable
if (decl->isDataseg()) {
Logger::println("data segment");
assert(!(decl->storage_class & STCmanifest) &&
"manifest constant being codegen'd!");
assert(!irs->dcomputetarget);
IrGlobal *irGlobal = getIrGlobal(decl);
LLGlobalVariable *gvar = llvm::cast<LLGlobalVariable>(irGlobal->value);
assert(gvar && "DtoResolveVariable should have created value");
if (global.params.vtls && gvar->isThreadLocal() &&
!(decl->storage_class & STCtemp)) {
const char *p = decl->loc.toChars();
fprintf(global.stdmsg, "%s: %s is thread local\n", p, decl->toChars());
}
// Check if we are defining or just declaring the global in this module.
// If we reach here during codegen of an available_externally function,
// new variable declarations should stay external and therefore must not
// have an initializer.
if (!(decl->storage_class & STCextern) && !decl->inNonRoot()) {
// Build the initializer. Might use irGlobal->value!
LLConstant *initVal =
DtoConstInitializer(decl->loc, decl->type, decl->_init);
// Cache it.
assert(!irGlobal->constInit);
irGlobal->constInit = initVal;
// Set the initializer, swapping out the variable if the types do not
// match.
irGlobal->value = irs->setGlobalVarInitializer(gvar, initVal);
// Finalize linkage & DLL storage class.
const auto lwc = DtoLinkage(decl);
setLinkage(lwc, gvar);
if (gvar->hasDLLImportStorageClass()) {
gvar->setDLLStorageClass(LLGlobalValue::DLLExportStorageClass);
}
// Also set up the debug info.
irs->DBuilder.EmitGlobalVariable(gvar, decl);
}
// If this global is used from a naked function, we need to create an
// artificial "use" for it, or it could be removed by the optimizer if
// the only reference to it is in inline asm.
if (irGlobal->nakedUse) {
irs->usedArray.push_back(gvar);
}
IF_LOG Logger::cout() << *gvar << '\n';
}
}