1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

Merge branch 'noreturn' into 'master'

Sprinkle some [[noreturn]] where possible

See merge request OpenMW/openmw!793
This commit is contained in:
Evil Eye 2021-06-24 19:21:29 +00:00
commit 0998929608
13 changed files with 18 additions and 20 deletions

View File

@ -33,7 +33,7 @@ using namespace Bsa;
/// Error handling
void BSAFile::fail(const std::string &msg)
[[noreturn]] void BSAFile::fail(const std::string &msg)
{
throw std::runtime_error("BSA Error: " + msg + "\nArchive: " + mFilename);
}

View File

@ -106,7 +106,7 @@ protected:
Lookup mLookup;
/// Error handling
void fail(const std::string &msg);
[[noreturn]] void fail(const std::string &msg);
/// Read header information from the input source
virtual void readHeader();

View File

@ -10,7 +10,7 @@ namespace Compiler
{
// Report the error and throw an exception.
void Parser::reportSeriousError (const std::string& message, const TokenLoc& loc)
[[noreturn]] void Parser::reportSeriousError (const std::string& message, const TokenLoc& loc)
{
mErrorHandler.error (message, loc);
throw SourceException();
@ -25,7 +25,7 @@ namespace Compiler
// Report an unexpected EOF condition.
void Parser::reportEOF()
[[noreturn]] void Parser::reportEOF()
{
mErrorHandler.endOfFile();
throw EOFException();

View File

@ -23,13 +23,13 @@ namespace Compiler
protected:
void reportSeriousError (const std::string& message, const TokenLoc& loc);
[[noreturn]] void reportSeriousError (const std::string& message, const TokenLoc& loc);
///< Report the error and throw a exception.
void reportWarning (const std::string& message, const TokenLoc& loc);
///< Report the warning without throwing an exception.
void reportEOF();
[[noreturn]] void reportEOF();
///< Report an unexpected EOF condition.
ErrorHandler& getErrorHandler();

View File

@ -315,7 +315,7 @@ std::string ESMReader::getString(int size)
return std::string (ptr, size);
}
void ESMReader::fail(const std::string &msg)
[[noreturn]] void ESMReader::fail(const std::string &msg)
{
std::stringstream ss;

View File

@ -250,7 +250,7 @@ public:
void skip(int bytes);
/// Used for error handling
void fail(const std::string &msg);
[[noreturn]] void fail(const std::string &msg);
/// Sets font encoder for ESM strings
void setEncoder(ToUTF8::Utf8Encoder* encoder);

View File

@ -132,7 +132,7 @@ namespace
return encoder.getUtf8(std::string(1, c));
}
void fail (Files::IStreamPtr file, const std::string& fileName, const std::string& message)
[[noreturn]] void fail (Files::IStreamPtr file, const std::string& fileName, const std::string& message)
{
std::stringstream error;
error << "Font loading error: " << message;

View File

@ -81,13 +81,13 @@ namespace Interpreter
abortUnknownSegment (code);
}
void Interpreter::abortUnknownCode (int segment, int opcode)
[[noreturn]] void Interpreter::abortUnknownCode (int segment, int opcode)
{
const std::string error = "unknown opcode " + std::to_string(opcode) + " in segment " + std::to_string(segment);
throw std::runtime_error (error);
}
void Interpreter::abortUnknownSegment (Type_Code code)
[[noreturn]] void Interpreter::abortUnknownSegment (Type_Code code)
{
const std::string error = "opcode outside of the allocated segment range: " + std::to_string(code);
throw std::runtime_error (error);

View File

@ -28,9 +28,9 @@ namespace Interpreter
void execute (Type_Code code);
void abortUnknownCode (int segment, int opcode);
[[noreturn]] void abortUnknownCode (int segment, int opcode);
void abortUnknownSegment (Type_Code code);
[[noreturn]] void abortUnknownSegment (Type_Code code);
void begin();

View File

@ -92,11 +92,9 @@ public:
};
/// Used if file parsing fails
void fail(const std::string &msg) const
[[noreturn]] void fail(const std::string &msg) const
{
std::string err = " NIFFile Error: " + msg;
err += "\nFile: " + filename;
throw std::runtime_error(err);
throw std::runtime_error(" NIFFile Error: " + msg + "\nFile: " + filename);
}
/// Used when something goes wrong, but not catastrophically so
void warn(const std::string &msg) const

View File

@ -43,7 +43,7 @@ public:
Log(Debug::Warning) << "NIFLoader: Warn: " << msg;
}
void fail(const std::string &msg)
[[noreturn]] void fail(const std::string &msg)
{
Log(Debug::Error) << "NIFLoader: Fail: "<< msg;
abort();

View File

@ -318,7 +318,7 @@ bool Settings::SettingsFileParser::skipWhiteSpace(size_t& i, std::string& str)
return i < str.size();
}
void Settings::SettingsFileParser::fail(const std::string& message)
[[noreturn]] void Settings::SettingsFileParser::fail(const std::string& message)
{
std::stringstream error;
error << "Error on line " << mLine << " in " << mFile << ":\n" << message;

View File

@ -20,7 +20,7 @@ namespace Settings
/// @return false if we have reached the end of the string
bool skipWhiteSpace(size_t& i, std::string& str);
void fail(const std::string& message);
[[noreturn]] void fail(const std::string& message);
std::string mFile;
int mLine = 0;