[Lldb-commits] [lldb] r121225 - /lldb/trunk/source/Symbol/ClangASTContext.cpp
Sean Callanan
scallanan at apple.com
Tue Dec 7 17:51:31 PST 2010
Author: spyffe
Date: Tue Dec 7 19:51:31 2010
New Revision: 121225
URL: http://llvm.org/viewvc/llvm-project?rev=121225&view=rev
Log:
Fixed a problem where the AST importer would assert()
because the diagnostic client for one of the AST
contexts is NULL. Now we provide a form of Miranda
rights to AST contexts: they are provided with a very
simple diagnostic client if they do not have one
themselves.
Modified:
lldb/trunk/source/Symbol/ClangASTContext.cpp
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=121225&r1=121224&r2=121225&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Dec 7 19:51:31 2010
@@ -747,7 +747,25 @@
ASTContext *src_ast,
clang_type_t clang_type)
{
- // null_client's ownership is transferred to diagnostics
+ // we temporarily install diagnostic clients as needed to ensure that
+ // errors are properly handled
+
+ std::auto_ptr<NullDiagnosticClient> diag_client;
+
+ bool dst_needs_diag = !dst_ast->getDiagnostics().getClient();
+ bool src_needs_diag = !src_ast->getDiagnostics().getClient();
+
+ if (dst_needs_diag || src_needs_diag)
+ {
+ diag_client.reset(new NullDiagnosticClient);
+
+ if (dst_needs_diag)
+ dst_ast->getDiagnostics().setClient(diag_client.get(), false);
+
+ if (src_needs_diag)
+ src_ast->getDiagnostics().setClient(diag_client.get(), false);
+ }
+
FileSystemOptions file_system_options;
FileManager file_manager (file_system_options);
ASTImporter importer(*dst_ast, file_manager,
@@ -756,6 +774,12 @@
QualType src (QualType::getFromOpaquePtr(clang_type));
QualType dst (importer.Import(src));
+ if (dst_needs_diag)
+ dst_ast->getDiagnostics().setClient(NULL, false);
+
+ if (src_needs_diag)
+ src_ast->getDiagnostics().setClient(NULL, false);
+
return dst.getAsOpaquePtr();
}
@@ -765,12 +789,36 @@
ASTContext *src_ast,
clang::Decl *source_decl)
{
- // null_client's ownership is transferred to diagnostics
+ // we temporarily install diagnostic clients as needed to ensure that
+ // errors are properly handled
+
+ std::auto_ptr<NullDiagnosticClient> diag_client;
+
+ bool dst_needs_diag = !dst_ast->getDiagnostics().getClient();
+ bool src_needs_diag = !src_ast->getDiagnostics().getClient();
+
+ if (dst_needs_diag || src_needs_diag)
+ {
+ diag_client.reset(new NullDiagnosticClient);
+
+ if (dst_needs_diag)
+ dst_ast->getDiagnostics().setClient(diag_client.get(), false);
+
+ if (src_needs_diag)
+ src_ast->getDiagnostics().setClient(diag_client.get(), false);
+ }
+
FileSystemOptions file_system_options;
FileManager file_manager (file_system_options);
ASTImporter importer(*dst_ast, file_manager,
*src_ast, file_manager);
+ if (dst_needs_diag)
+ dst_ast->getDiagnostics().setClient(NULL, false);
+
+ if (src_needs_diag)
+ src_ast->getDiagnostics().setClient(NULL, false);
+
return importer.Import(source_decl);
}
More information about the lldb-commits
mailing list