Fix crash when trying to generate debug info with program source from stdin

This commit is contained in:
Matt Pharr
2011-07-27 07:42:47 +01:00
parent 922dbdec06
commit 8aea4a836d

View File

@@ -118,16 +118,27 @@ Module::Module(const char *fn) {
// If we're generating debugging symbols, let the DIBuilder know that // If we're generating debugging symbols, let the DIBuilder know that
// we're starting a new compilation unit. // we're starting a new compilation unit.
if (diBuilder != NULL) { if (diBuilder != NULL) {
std::string directory, name; if (filename == NULL) {
GetDirectoryAndFileName(g->currentDirectory, filename, &directory, // Unfortunately we can't yet call Error() since the global 'm'
&name); // variable hasn't been initialized yet.
diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */ fprintf(stderr, "Can't emit debugging information with no "
name, /* filename */ "source file on disk.\n");
directory, /* directory */ ++errorCount;
"ispc", /* producer */ delete diBuilder;
g->opt.level > 0 /* is optimized */, diBuilder = NULL;
"-g", /* command line args */ }
0 /* run time version */); else {
std::string directory, name;
GetDirectoryAndFileName(g->currentDirectory, filename, &directory,
&name);
diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */
name, /* filename */
directory, /* directory */
"ispc", /* producer */
g->opt.level > 0 /* is optimized */,
"-g", /* command line args */
0 /* run time version */);
}
} }
#endif // LLVM_2_8 #endif // LLVM_2_8
} }