comparison gen/toobj.cpp @ 149:4c577c2b7229 trunk

[svn r155] Fixed a bunch of linkage problems (especially with templates)
author lindquist
date Mon, 24 Mar 2008 19:43:02 +0100
parents 0ab29b838084
children 7f92f477ff53
comparison
equal deleted inserted replaced
148:86d3bb8ca33e 149:4c577c2b7229
517 517
518 irGlobal = new IrGlobal(this); 518 irGlobal = new IrGlobal(this);
519 519
520 Logger::println("parent: %s (%s)", parent->toChars(), parent->kind()); 520 Logger::println("parent: %s (%s)", parent->toChars(), parent->kind());
521 521
522 // handle static local variables
523 bool static_local = false;
522 bool _isconst = isConst(); 524 bool _isconst = isConst();
523 if (parent && parent->isFuncDeclaration() && init && init->isExpInitializer()) 525 if (parent && parent->isFuncDeclaration())
524 _isconst = false; 526 {
525 527 static_local = true;
526 llvm::GlobalValue::LinkageTypes _linkage; 528 if (init && init->isExpInitializer()) {
527 bool istempl = false; 529 _isconst = false;
528 bool static_local = false; 530 }
529 if ((storage_class & STCcomdat) || (parent && DtoIsTemplateInstance(parent))) {
530 _linkage = llvm::GlobalValue::WeakLinkage;
531 istempl = true;
532 } 531 }
533 else if (parent && parent->isFuncDeclaration()) { 532
534 _linkage = llvm::GlobalValue::InternalLinkage; 533 Logger::println("Creating global variable");
535 static_local = true;
536 }
537 else
538 _linkage = DtoLinkage(protection, storage_class);
539 534
540 const llvm::Type* _type = irGlobal->type.get(); 535 const llvm::Type* _type = irGlobal->type.get();
541 536 llvm::GlobalValue::LinkageTypes _linkage = DtoLinkage(this);
542 Logger::println("Creating global variable");
543 std::string _name(mangle()); 537 std::string _name(mangle());
544 538
545 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_type,_isconst,_linkage,NULL,_name,gIR->module); 539 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_type,_isconst,_linkage,NULL,_name,gIR->module);
546 irGlobal->value = gvar; 540 irGlobal->value = gvar;
547 541