When given unsaved files in clang_createTranslationUnitFromSourceFile,

copy the source buffers provided rather than referencing them
directly, so that the caller can free those buffers immediately after
calling clang_createTranslationUnitFromSourceFile(). Otherwise, we
risk hitting those buffers later (when building source ranges, forming
diagnostics, etc.). 

llvm-svn: 97296
This commit is contained in:
Douglas Gregor
2010-02-27 01:32:48 +00:00
parent e7179e8b76
commit 89a56c561f
4 changed files with 6 additions and 6 deletions

View File

@@ -439,6 +439,7 @@ static void InitializeFileRemapping(Diagnostic &Diags,
if (!FromFile) {
Diags.Report(diag::err_fe_remap_missing_from_file)
<< Remap->first;
delete Remap->second;
continue;
}
@@ -477,7 +478,7 @@ static void InitializeFileRemapping(Diagnostic &Diags,
= llvm::MemoryBuffer::getFile(ToFile->getName(), &ErrorStr);
if (!Buffer) {
Diags.Report(diag::err_fe_error_opening)
<< Remap->second << ErrorStr;
<< Remap->second << ErrorStr;
continue;
}