-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compiler warnings and add tests for them (#216)
* Add warning for generic types with single type condition * Add more tests for warnings * Separate lexer and parser errors * Add testing mechanism for warnings * Fix minor issues and update test refs * Fix Windows paths in warnings
- Loading branch information
1 parent
ec3eb03
commit 105a941
Showing
148 changed files
with
399 additions
and
223 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2021-2022 ChilliBits. All rights reserved. | ||
|
||
#include "LexerError.h" | ||
|
||
#include <util/CodeLoc.h> | ||
|
||
/** | ||
* Constructor: Used in case that the exact code position where the error occurred is known | ||
* | ||
* @param codeLoc Code location where the error occurred | ||
* @param type Type of the error | ||
* @param message Error message suffix | ||
*/ | ||
LexerError::LexerError(const CodeLoc &codeLoc, const LexerErrorType &type, const std::string &message) { | ||
errorMessage = "[Error|Lexer] " + codeLoc.toPrettyString() + ": " + getMessagePrefix(type) + ": " + message; | ||
} | ||
|
||
/** | ||
* Get the message for this particular error instance | ||
* | ||
* @return Error message in form of a char array | ||
*/ | ||
const char *LexerError::what() const noexcept { return errorMessage.c_str(); } | ||
|
||
/** | ||
* Get the prefix of the error message for a particular error | ||
* | ||
* @param type Type of the error | ||
* @return Prefix string for the error type | ||
*/ | ||
std::string LexerError::getMessagePrefix(LexerErrorType type) { | ||
switch (type) { | ||
case TOKENIZING_FAILED: | ||
return "Tokenizing failed"; | ||
} | ||
return "Unknown error"; // GCOV_EXCL_LINE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2021-2022 ChilliBits. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include <exception> | ||
#include <string> | ||
#include <utility> | ||
|
||
// Forward declarations | ||
struct CodeLoc; | ||
|
||
enum LexerErrorType { TOKENIZING_FAILED }; | ||
|
||
/** | ||
* Custom exception for errors, occurring while lexing | ||
*/ | ||
class LexerError : public std::exception { | ||
public: | ||
// Constructors | ||
explicit LexerError(const CodeLoc &codeLoc, const LexerErrorType &type, const std::string &message); | ||
|
||
// Public methods | ||
[[nodiscard]] const char *what() const noexcept override; | ||
|
||
private: | ||
// Members | ||
std::string errorMessage; | ||
|
||
// Private methods | ||
[[nodiscard]] static std::string getMessagePrefix(LexerErrorType errorType); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.