Clarify the ownership semantics of the Diagnostic object used by

ASTUnit. Previously, we would end up with use-after-free errors
because the Diagnostic object would be creating in one place (say,
CIndex) and its ownership would not be transferred into the
ASTUnit. Fixes <rdar://problem/7818608>.

llvm-svn: 100464
This commit is contained in:
Douglas Gregor
2010-04-05 21:10:19 +00:00
parent 41e692dcf1
commit d03e823fb4
5 changed files with 87 additions and 38 deletions

View File

@@ -37,7 +37,8 @@ void ASTMergeAction::ExecuteAction() {
CI.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument,
&CI.getASTContext());
for (unsigned I = 0, N = ASTFiles.size(); I != N; ++I) {
ASTUnit *Unit = ASTUnit::LoadFromPCHFile(ASTFiles[I], CI.getDiagnostics(),
ASTUnit *Unit = ASTUnit::LoadFromPCHFile(ASTFiles[I],
UnownedDiag(CI.getDiagnostics()),
false);
if (!Unit)
continue;