From ca564c4a502a932e26ab03b5d7d3002b29840a90 Mon Sep 17 00:00:00 2001 From: oh-rgx Date: Thu, 5 Jun 2025 17:24:41 +0800 Subject: [PATCH] fix diagnostic flush Issue: #ICDC8T Signed-off-by: oh-rgx --- ets2panda/public/es2panda_lib.cpp | 4 +++- ets2panda/util/diagnosticEngine.cpp | 4 ---- ets2panda/util/diagnosticEngine.h | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index 8df91d24af..14a173532e 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -501,7 +501,9 @@ __attribute__((unused)) static Context *Parse(Context *ctx) ctx->config->options->GetCompilationMode() == CompilationMode::GEN_STD_LIB); } ctx->state = !ctx->diagnosticEngine->IsAnyError() ? ES2PANDA_STATE_PARSED : ES2PANDA_STATE_ERROR; - ctx->diagnosticEngine->FlushDiagnostic(); + if (ctx->state == ES2PANDA_STATE_ERROR) { + ctx->diagnosticEngine->FlushDiagnostic(); + } ctx->phaseManager->SetCurrentPhaseIdToAfterParse(); return ctx; } diff --git a/ets2panda/util/diagnosticEngine.cpp b/ets2panda/util/diagnosticEngine.cpp index 9660f1f160..1108b9e7f1 100644 --- a/ets2panda/util/diagnosticEngine.cpp +++ b/ets2panda/util/diagnosticEngine.cpp @@ -61,9 +61,6 @@ DiagnosticStorage DiagnosticEngine::GetAllDiagnostic() void DiagnosticEngine::FlushDiagnostic() { - if (isFlushed_) { - return; - } auto log = GetAllDiagnostic(); std::sort(log.begin(), log.end(), [](const auto &lhs, const auto &rhs) { return *lhs < *rhs; }); auto last = @@ -71,7 +68,6 @@ void DiagnosticEngine::FlushDiagnostic() for (auto it = log.begin(); it != last; it++) { printer_->Print(**it); } - isFlushed_ = true; } #ifndef FUZZING_EXIT_ON_FAILED_ASSERT static void SigSegvHandler([[maybe_unused]] int sig) diff --git a/ets2panda/util/diagnosticEngine.h b/ets2panda/util/diagnosticEngine.h index a013fc7a71..015dc4d6ad 100644 --- a/ets2panda/util/diagnosticEngine.h +++ b/ets2panda/util/diagnosticEngine.h @@ -172,7 +172,6 @@ private: std::array(DiagnosticType::COUNT)> diagnostics_; std::unique_ptr printer_; bool wError_ {false}; - bool isFlushed_ {false}; }; } // namespace ark::es2panda::util -- Gitee