comparison gen/todebug.cpp @ 1271:0686701178d3

Moved special casing of 'assert(this, "null this");' generated statements from !ThisExp into !AssertExp. Fixed filenames for array bounds errors and probably others, fixes #271 .
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Mon, 27 Apr 2009 13:30:48 +0200
parents 73b56541152c
children b8c2f3e05b52
comparison
equal deleted inserted replaced
1270:dd135ff697fa 1271:0686701178d3
474 { 474 {
475 Logger::println("D to dwarf compile_unit"); 475 Logger::println("D to dwarf compile_unit");
476 LOG_SCOPE; 476 LOG_SCOPE;
477 477
478 // we might be generating for an import 478 // we might be generating for an import
479 if (!m->ir.irModule) 479 IrModule* irmod = getIrModule(m);
480 m->ir.irModule = new IrModule(m, m->srcfile->toChars()); 480
481 else if (!m->ir.irModule->diCompileUnit.isNull()) 481 if (!irmod->diCompileUnit.isNull())
482 { 482 {
483 assert (m->ir.irModule->diCompileUnit.getGV()->getParent() == gIR->module 483 assert (irmod->diCompileUnit.getGV()->getParent() == gIR->module
484 && "debug info compile unit belongs to incorrect llvm module!"); 484 && "debug info compile unit belongs to incorrect llvm module!");
485 return m->ir.irModule->diCompileUnit; 485 return irmod->diCompileUnit;
486 } 486 }
487 487
488 // prepare srcpath 488 // prepare srcpath
489 std::string srcpath(FileName::path(m->srcfile->name->toChars())); 489 std::string srcpath(FileName::path(m->srcfile->name->toChars()));
490 if (!FileName::absolute(srcpath.c_str())) { 490 if (!FileName::absolute(srcpath.c_str())) {
494 if (!srcpath.empty() && *srcpath.rbegin() != '/' && *srcpath.rbegin() != '\\') 494 if (!srcpath.empty() && *srcpath.rbegin() != '/' && *srcpath.rbegin() != '\\')
495 srcpath = srcpath + '/'; 495 srcpath = srcpath + '/';
496 } 496 }
497 497
498 // make compile unit 498 // make compile unit
499 m->ir.irModule->diCompileUnit = gIR->difactory.CreateCompileUnit( 499 irmod->diCompileUnit = gIR->difactory.CreateCompileUnit(
500 global.params.symdebug == 2 ? DW_LANG_C : DW_LANG_D, 500 global.params.symdebug == 2 ? DW_LANG_C : DW_LANG_D,
501 m->srcfile->name->toChars(), 501 m->srcfile->name->toChars(),
502 srcpath, 502 srcpath,
503 "LDC (http://www.dsource.org/projects/ldc)", 503 "LDC (http://www.dsource.org/projects/ldc)",
504 //FIXME: What do these two mean? 504 //FIXME: What do these two mean?
507 ); 507 );
508 508
509 // if the linkage stays internal, we can't llvm-link the generated modules together: 509 // if the linkage stays internal, we can't llvm-link the generated modules together:
510 // llvm's DwarfWriter uses path and filename to determine the symbol name and we'd 510 // llvm's DwarfWriter uses path and filename to determine the symbol name and we'd
511 // end up with duplicate symbols 511 // end up with duplicate symbols
512 m->ir.irModule->diCompileUnit.getGV()->setLinkage(DEBUGINFO_LINKONCE_LINKAGE_TYPE); 512 irmod->diCompileUnit.getGV()->setLinkage(DEBUGINFO_LINKONCE_LINKAGE_TYPE);
513 m->ir.irModule->diCompileUnit.getGV()->setName(std::string("llvm.dbg.compile_unit_") + srcpath + m->srcfile->name->toChars()); 513 irmod->diCompileUnit.getGV()->setName(std::string("llvm.dbg.compile_unit_") + srcpath + m->srcfile->name->toChars());
514 514
515 return m->ir.irModule->diCompileUnit; 515 return irmod->diCompileUnit;
516 } 516 }
517 517
518 ////////////////////////////////////////////////////////////////////////////////////////////////// 518 //////////////////////////////////////////////////////////////////////////////////////////////////
519 519
520 llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd) 520 llvm::DISubprogram DtoDwarfSubProgram(FuncDeclaration* fd)