From 2a2794da233a591e3d62b67c34eb5189afdc48ab Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Fri, 1 Dec 2017 09:36:32 -0800 Subject: [PATCH] Also log arguments when failing to create a translation unit --- src/clang_translation_unit.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/clang_translation_unit.cc b/src/clang_translation_unit.cc index ff9ddb9c..b2fbec2a 100644 --- a/src/clang_translation_unit.cc +++ b/src/clang_translation_unit.cc @@ -24,8 +24,14 @@ namespace { // std::mutex g_parse_translation_unit_mutex; // std::mutex g_reparse_translation_unit_mutex; -void EmitDiagnostics(std::string path, CXTranslationUnit tu) { +void EmitDiagnostics(std::string path, + std::vector args, + CXTranslationUnit tu) { std::string output = "Fatal errors while trying to parse " + path + "\n"; + output += + "Args: " + + StringJoinMap(args, [](const char* arg) { return std::string(arg); }) + + "\n"; size_t num_diagnostics = clang_getNumDiagnostics(tu); for (unsigned i = 0; i < num_diagnostics; ++i) { @@ -97,7 +103,7 @@ std::unique_ptr ClangTranslationUnit::Create( } if (error_code != CXError_Success && cx_tu) - EmitDiagnostics(filepath, cx_tu); + EmitDiagnostics(filepath, args, cx_tu); switch (error_code) { case CXError_Success: @@ -136,7 +142,7 @@ std::unique_ptr ClangTranslationUnit::Reparse( } if (error_code != CXError_Success && tu->cx_tu) - EmitDiagnostics("", tu->cx_tu); + EmitDiagnostics("", {}, tu->cx_tu); switch (error_code) { case CXError_Success: