From fb8b7098a11cea50c63c9b190541cc624cc211c6 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Thu, 28 Oct 2010 18:19:36 +0000 Subject: [PATCH] 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. llvm-svn: 117568 --- lldb/source/Symbol/ClangASTContext.cpp | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index c5d1cc611368..efea85acb45b 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -32,6 +32,7 @@ #include "lldb/Core/dwarf.h" #include "lldb/Core/Flags.h" +#include "lldb/Core/Log.h" #include @@ -710,12 +711,35 @@ ClangASTContext::GetVoidPtrType (ASTContext *ast_context, bool is_const) 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 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 @@ ClangASTContext::AddMethodToObjCObjectType 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;