[Lldb-commits] [lldb] r121601 - in /lldb/trunk: include/lldb/Core/ClangForward.h include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp

Sean Callanan scallanan at apple.com
Fri Dec 10 16:08:56 PST 2010


Author: spyffe
Date: Fri Dec 10 18:08:56 2010
New Revision: 121601

URL: http://llvm.org/viewvc/llvm-project?rev=121601&view=rev
Log:
Made all LLDB-generated ASTContexts have valid
DiagnosticClients, and removed code that was patching
over the original problem.

Modified:
    lldb/trunk/include/lldb/Core/ClangForward.h
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/include/lldb/Core/ClangForward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=121601&r1=121600&r2=121601&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ClangForward.h (original)
+++ lldb/trunk/include/lldb/Core/ClangForward.h Fri Dec 10 18:08:56 2010
@@ -51,6 +51,7 @@
     class DeclStmt;
     class DependencyOutputOptions;
     class Diagnostic;
+    class DiagnosticClient;
     class DiagnosticOptions;
     class EnumDecl;
     class Expr;

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=121601&r1=121600&r2=121601&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Dec 10 18:08:56 2010
@@ -80,6 +80,9 @@
 
     clang::Diagnostic *
     getDiagnostic();
+    
+    clang::DiagnosticClient *
+    getDiagnosticClient();
 
     clang::TargetOptions *
     getTargetOptions();
@@ -614,6 +617,7 @@
     std::auto_ptr<clang::FileSystemOptions> m_file_system_options_ap;
     std::auto_ptr<clang::SourceManager>     m_source_manager_ap;
     std::auto_ptr<clang::Diagnostic>        m_diagnostic_ap;
+    std::auto_ptr<clang::DiagnosticClient>  m_diagnostic_client_ap;
     std::auto_ptr<clang::TargetOptions>     m_target_options_ap;
     std::auto_ptr<clang::TargetInfo>        m_target_info_ap;
     std::auto_ptr<clang::IdentifierTable>   m_identifier_table_ap;

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=121601&r1=121600&r2=121601&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Dec 10 18:08:56 2010
@@ -312,6 +312,8 @@
                 *getSelectorTable(),
                 *getBuiltinContext(),
                 0));
+        
+        m_ast_context_ap->getDiagnostics().setClient(getDiagnosticClient(), false);
     }
     return m_ast_context_ap.get();
 }
@@ -382,6 +384,37 @@
     return m_diagnostic_ap.get();
 }
 
+class NullDiagnosticClient : public DiagnosticClient
+{
+public:
+    NullDiagnosticClient ()
+    {
+        m_log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
+    }
+    
+    void HandleDiagnostic (Diagnostic::Level DiagLevel, const DiagnosticInfo &info)
+    {
+        if (m_log)
+        {
+            llvm::SmallVectorImpl<char> diag_str(10);
+            info.FormatDiagnostic(diag_str);
+            diag_str.push_back('\0');
+            m_log->Printf("Compiler diagnostic: %s\n", diag_str.data());
+        }
+    }
+private:
+    LogSP m_log;
+};
+
+DiagnosticClient *
+ClangASTContext::getDiagnosticClient()
+{
+    if (m_diagnostic_client_ap.get() == NULL)
+        m_diagnostic_client_ap.reset(new NullDiagnosticClient);
+    
+    return m_diagnostic_client_ap.get();
+}
+
 TargetOptions *
 ClangASTContext::getTargetOptions()
 {
@@ -720,52 +753,11 @@
     return void_ptr_type.getAsOpaquePtr();
 }
 
-class NullDiagnosticClient : public DiagnosticClient
-{
-public:
-    NullDiagnosticClient ()
-    {
-        m_log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
-    }
-    
-    void HandleDiagnostic (Diagnostic::Level DiagLevel, const DiagnosticInfo &info)
-    {
-        if (m_log)
-        {
-            llvm::SmallVectorImpl<char> diag_str(10);
-            info.FormatDiagnostic(diag_str);
-            diag_str.push_back('\0');
-            m_log->Printf("Compiler diagnostic: %s\n", diag_str.data());
-        }
-    }
-private:
-    LogSP m_log;
-};
-
 clang_type_t
 ClangASTContext::CopyType (ASTContext *dst_ast, 
                            ASTContext *src_ast,
                            clang_type_t clang_type)
 {
-    // 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,
@@ -774,12 +766,6 @@
     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();
 }
 
@@ -788,37 +774,12 @@
 ClangASTContext::CopyDecl (ASTContext *dst_ast, 
                            ASTContext *src_ast,
                            clang::Decl *source_decl)
-{
-    // 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