mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 13:09:40 +00:00
Merge branch 'noreturn' into 'master'
Sprinkle some [[noreturn]] where possible See merge request OpenMW/openmw!793
This commit is contained in:
commit
0998929608
13 changed files with 18 additions and 20 deletions
|
@ -33,7 +33,7 @@ using namespace Bsa;
|
||||||
|
|
||||||
|
|
||||||
/// Error handling
|
/// 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);
|
throw std::runtime_error("BSA Error: " + msg + "\nArchive: " + mFilename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ protected:
|
||||||
Lookup mLookup;
|
Lookup mLookup;
|
||||||
|
|
||||||
/// Error handling
|
/// Error handling
|
||||||
void fail(const std::string &msg);
|
[[noreturn]] void fail(const std::string &msg);
|
||||||
|
|
||||||
/// Read header information from the input source
|
/// Read header information from the input source
|
||||||
virtual void readHeader();
|
virtual void readHeader();
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Compiler
|
||||||
{
|
{
|
||||||
// Report the error and throw an exception.
|
// 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);
|
mErrorHandler.error (message, loc);
|
||||||
throw SourceException();
|
throw SourceException();
|
||||||
|
@ -25,7 +25,7 @@ namespace Compiler
|
||||||
|
|
||||||
// Report an unexpected EOF condition.
|
// Report an unexpected EOF condition.
|
||||||
|
|
||||||
void Parser::reportEOF()
|
[[noreturn]] void Parser::reportEOF()
|
||||||
{
|
{
|
||||||
mErrorHandler.endOfFile();
|
mErrorHandler.endOfFile();
|
||||||
throw EOFException();
|
throw EOFException();
|
||||||
|
|
|
@ -23,13 +23,13 @@ namespace Compiler
|
||||||
|
|
||||||
protected:
|
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.
|
///< Report the error and throw a exception.
|
||||||
|
|
||||||
void reportWarning (const std::string& message, const TokenLoc& loc);
|
void reportWarning (const std::string& message, const TokenLoc& loc);
|
||||||
///< Report the warning without throwing an exception.
|
///< Report the warning without throwing an exception.
|
||||||
|
|
||||||
void reportEOF();
|
[[noreturn]] void reportEOF();
|
||||||
///< Report an unexpected EOF condition.
|
///< Report an unexpected EOF condition.
|
||||||
|
|
||||||
ErrorHandler& getErrorHandler();
|
ErrorHandler& getErrorHandler();
|
||||||
|
|
|
@ -315,7 +315,7 @@ std::string ESMReader::getString(int size)
|
||||||
return std::string (ptr, size);
|
return std::string (ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESMReader::fail(const std::string &msg)
|
[[noreturn]] void ESMReader::fail(const std::string &msg)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ public:
|
||||||
void skip(int bytes);
|
void skip(int bytes);
|
||||||
|
|
||||||
/// Used for error handling
|
/// Used for error handling
|
||||||
void fail(const std::string &msg);
|
[[noreturn]] void fail(const std::string &msg);
|
||||||
|
|
||||||
/// Sets font encoder for ESM strings
|
/// Sets font encoder for ESM strings
|
||||||
void setEncoder(ToUTF8::Utf8Encoder* encoder);
|
void setEncoder(ToUTF8::Utf8Encoder* encoder);
|
||||||
|
|
|
@ -132,7 +132,7 @@ namespace
|
||||||
return encoder.getUtf8(std::string(1, c));
|
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;
|
std::stringstream error;
|
||||||
error << "Font loading error: " << message;
|
error << "Font loading error: " << message;
|
||||||
|
|
|
@ -81,13 +81,13 @@ namespace Interpreter
|
||||||
abortUnknownSegment (code);
|
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);
|
const std::string error = "unknown opcode " + std::to_string(opcode) + " in segment " + std::to_string(segment);
|
||||||
throw std::runtime_error (error);
|
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);
|
const std::string error = "opcode outside of the allocated segment range: " + std::to_string(code);
|
||||||
throw std::runtime_error (error);
|
throw std::runtime_error (error);
|
||||||
|
|
|
@ -28,9 +28,9 @@ namespace Interpreter
|
||||||
|
|
||||||
void execute (Type_Code code);
|
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();
|
void begin();
|
||||||
|
|
||||||
|
|
|
@ -92,11 +92,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Used if file parsing fails
|
/// 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;
|
throw std::runtime_error(" NIFFile Error: " + msg + "\nFile: " + filename);
|
||||||
err += "\nFile: " + filename;
|
|
||||||
throw std::runtime_error(err);
|
|
||||||
}
|
}
|
||||||
/// Used when something goes wrong, but not catastrophically so
|
/// Used when something goes wrong, but not catastrophically so
|
||||||
void warn(const std::string &msg) const
|
void warn(const std::string &msg) const
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
Log(Debug::Warning) << "NIFLoader: Warn: " << msg;
|
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;
|
Log(Debug::Error) << "NIFLoader: Fail: "<< msg;
|
||||||
abort();
|
abort();
|
||||||
|
|
|
@ -318,7 +318,7 @@ bool Settings::SettingsFileParser::skipWhiteSpace(size_t& i, std::string& str)
|
||||||
return i < str.size();
|
return i < str.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::SettingsFileParser::fail(const std::string& message)
|
[[noreturn]] void Settings::SettingsFileParser::fail(const std::string& message)
|
||||||
{
|
{
|
||||||
std::stringstream error;
|
std::stringstream error;
|
||||||
error << "Error on line " << mLine << " in " << mFile << ":\n" << message;
|
error << "Error on line " << mLine << " in " << mFile << ":\n" << message;
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Settings
|
||||||
/// @return false if we have reached the end of the string
|
/// @return false if we have reached the end of the string
|
||||||
bool skipWhiteSpace(size_t& i, std::string& str);
|
bool skipWhiteSpace(size_t& i, std::string& str);
|
||||||
|
|
||||||
void fail(const std::string& message);
|
[[noreturn]] void fail(const std::string& message);
|
||||||
|
|
||||||
std::string mFile;
|
std::string mFile;
|
||||||
int mLine = 0;
|
int mLine = 0;
|
||||||
|
|
Loading…
Reference in a new issue