From ba505b29e46c5af45fb255dafc6f584de2d5ceb7 Mon Sep 17 00:00:00 2001 From: tengtengh Date: Fri, 25 Jul 2025 15:21:19 +0800 Subject: [PATCH] fix DiagnosticEngine when compile project Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICOTPY Signed-off-by: tengtengh --- ets2panda/aot/main.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index 2782245c60..8e1d99e3c2 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -198,23 +198,23 @@ static int Run(Span args) return 1; } + int res; if (options->GetCompilationMode() == CompilationMode::PROJECT) { - diagnosticEngine.FlushDiagnostic(); - return CompileFromConfig(compiler, options.get(), diagnosticEngine); - } - - std::string sourceFile; - std::string_view parserInput; - if (options->GetCompilationMode() == CompilationMode::GEN_STD_LIB) { - sourceFile = "etsstdlib.ets"; - parserInput = ""; + res = CompileFromConfig(compiler, options.get(), diagnosticEngine); } else { - sourceFile = options->SourceFileName(); - auto [buf, size] = options->CStrParserInputContents(); - parserInput = std::string_view(buf, size); + std::string sourceFile; + std::string_view parserInput; + if (options->GetCompilationMode() == CompilationMode::GEN_STD_LIB) { + sourceFile = "etsstdlib.ets"; + parserInput = ""; + } else { + sourceFile = options->SourceFileName(); + auto [buf, size] = options->CStrParserInputContents(); + parserInput = std::string_view(buf, size); + } + es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); + res = CompileFromSource(compiler, input, *options.get(), diagnosticEngine); } - es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); - auto res = CompileFromSource(compiler, input, *options.get(), diagnosticEngine); diagnosticEngine.FlushDiagnostic(); return res; } -- Gitee