1 /** 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "util/es2pandaMacros.h" 17 #include "util/diagnosticEngine.h" 18 #include "util/options.h" 19 #include "parser/program/program.h" 20 21 namespace ark::es2panda { GetPositionForDiagnostic()22lexer::SourcePosition GetPositionForDiagnostic() 23 { 24 return lexer::SourcePosition {}; 25 } 26 CompilerBugAction(const lexer::SourcePosition & position)27void CompilerBugAction(const lexer::SourcePosition &position) 28 { 29 if (g_diagnosticEngine != nullptr) { 30 g_diagnosticEngine->FlushDiagnostic(); 31 } 32 33 std::cerr << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; 34 std::cerr << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; 35 std::cerr << std::endl; 36 37 std::cerr << "es2panda unexpectedly terminated"; 38 auto program = position.Program(); 39 if (program != nullptr) { 40 auto loc = position.ToLocation(); 41 std::cerr << " during processing [" << util::BaseName(program->SourceFilePath().Utf8()); 42 std::cerr << ":" << loc.line << ":" << loc.col << "]"; 43 } 44 std::cerr << "." << std::endl; 45 46 std::cerr << "PLEASE submit a bug report to "; 47 std::cerr << "https://gitee.com/openharmony/arkcompiler_ets_frontend/issues"; 48 std::cerr << " and include the crash backtrace, source code and associated run script. "; 49 std::cerr << std::endl; 50 } 51 } // namespace ark::es2panda 52