From 411949babbdbe647880d77c87924a58efdc7f194 Mon Sep 17 00:00:00 2001 From: maelhos <52194580+maelhos@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:31:01 +0100 Subject: [PATCH] Stop using runtime C++ exceptions As of LLVM 18, llvm-config contains -fno-exceptions, general standard are also moving off runtime exceptions in C++ https://stackoverflow.com/questions/4506369/when-and-how-should-i-use-exception-handling . --- src/plugins/cpp/templates/lr.template.h | 2 +- src/plugins/cpp/templates/tokenizer.template.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/cpp/templates/lr.template.h b/src/plugins/cpp/templates/lr.template.h index 6a638f6..6803e17 100644 --- a/src/plugins/cpp/templates/lr.template.h +++ b/src/plugins/cpp/templates/lr.template.h @@ -250,7 +250,7 @@ class {{{PARSER_CLASS_NAME}}} { if (token->type == TokenType::__EOF && !tokenizer.hasMoreTokens()) { std::string errMsg = "Unexpected end of input.\n"; std::cerr << errMsg; - throw std::runtime_error(errMsg.c_str()); + std::exit(EXIT_FAILURE); } tokenizer.throwUnexpectedToken(token->value, token->startLine, token->startColumn); diff --git a/src/plugins/cpp/templates/tokenizer.template.h b/src/plugins/cpp/templates/tokenizer.template.h index 798e98a..c56ddb5 100644 --- a/src/plugins/cpp/templates/tokenizer.template.h +++ b/src/plugins/cpp/templates/tokenizer.template.h @@ -204,7 +204,7 @@ class Tokenizer { << ":" << column << "\n\n"; std::cerr << errMsg.str(); - throw new std::runtime_error(errMsg.str().c_str()); + std::exit(1); } /**