[Lldb-commits] [lldb] r117568 - /lldb/trunk/source/Symbol/ClangASTContext.cpp

Sean Callanan scallanan at apple.com
Thu Oct 28 11:19:36 PDT 2010


Author: spyffe
Date: Thu Oct 28 13:19:36 2010
New Revision: 117568

URL: http://llvm.org/viewvc/llvm-project?rev=117568&view=rev
Log:
Logging fixes.  Added a simple class to handle
logging for type importing, making errors much
easier to diagnose.  Also removed some Objective-C
related logging.

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=117568&r1=117567&r2=117568&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Oct 28 13:19:36 2010
@@ -32,6 +32,7 @@
 
 #include "lldb/Core/dwarf.h"
 #include "lldb/Core/Flags.h"
+#include "lldb/Core/Log.h"
 
 #include <stdio.h>
 
@@ -710,12 +711,35 @@
     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:
+    Log    *m_log;
+};
+
 clang_type_t
 ClangASTContext::CopyType (ASTContext *dest_context, 
                            ASTContext *source_context,
                            clang_type_t clang_type)
 {
-    Diagnostic diagnostics;
+    NullDiagnosticClient *null_client = new NullDiagnosticClient;
+    Diagnostic diagnostics(null_client);
     FileManager file_manager;
     ASTImporter importer(diagnostics,
                          *dest_context, file_manager,
@@ -1573,7 +1597,6 @@
         bool has_arg = (start[len] == ':');
         if (has_arg)
             ++num_selectors_with_args;
-        printf ("@selector[%zu] = '%.*s'\n", selector_idents.size(), (int)len, start);
         selector_idents.push_back (&identifier_table->get (StringRef (start, len)));
         if (has_arg)
             len += 1;





More information about the lldb-commits mailing list