Report 'unknown macro' as information message with id unknownMacro
This commit is contained in:
parent
a50eb56d8d
commit
152be6df63
|
@ -451,14 +451,16 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
|
||||||
locationList.push_back(loc);
|
locationList.push_back(loc);
|
||||||
ErrorLogger::ErrorMessage errmsg(locationList,
|
ErrorLogger::ErrorMessage errmsg(locationList,
|
||||||
mTokenizer.list.getSourceFilePath(),
|
mTokenizer.list.getSourceFilePath(),
|
||||||
Severity::error,
|
e.type == InternalError::UNKNOWN_MACRO ? Severity::information : Severity::error,
|
||||||
e.errorMessage,
|
e.errorMessage,
|
||||||
e.id,
|
e.id,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
reportErr(errmsg);
|
if (errmsg._severity == Severity::error || mSettings.isEnabled(errmsg._severity)) {
|
||||||
if (!mSuppressInternalErrorFound)
|
reportErr(errmsg);
|
||||||
internalErrorFound = true;
|
if (!mSuppressInternalErrorFound)
|
||||||
|
internalErrorFound = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type type) :
|
InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type type) :
|
||||||
token(tok), errorMessage(errorMsg)
|
token(tok), errorMessage(errorMsg), type(type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AST:
|
case AST:
|
||||||
|
@ -43,6 +43,9 @@ InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type
|
||||||
case SYNTAX:
|
case SYNTAX:
|
||||||
id = "syntaxError";
|
id = "syntaxError";
|
||||||
break;
|
break;
|
||||||
|
case UNKNOWN_MACRO:
|
||||||
|
id = "unknownMacro";
|
||||||
|
break;
|
||||||
case INTERNAL:
|
case INTERNAL:
|
||||||
id = "cppcheckError";
|
id = "cppcheckError";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -54,10 +54,11 @@ namespace tinyxml2 {
|
||||||
|
|
||||||
/** @brief Simple container to be thrown when internal error is detected. */
|
/** @brief Simple container to be thrown when internal error is detected. */
|
||||||
struct InternalError {
|
struct InternalError {
|
||||||
enum Type {AST, SYNTAX, INTERNAL};
|
enum Type {AST, SYNTAX, UNKNOWN_MACRO, INTERNAL};
|
||||||
InternalError(const Token *tok, const std::string &errorMsg, Type type = INTERNAL);
|
InternalError(const Token *tok, const std::string &errorMsg, Type type = INTERNAL);
|
||||||
const Token *token;
|
const Token *token;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
|
Type type;
|
||||||
std::string id;
|
std::string id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7923,7 +7923,7 @@ void Tokenizer::syntaxErrorC(const Token *tok, const std::string &what) const
|
||||||
void Tokenizer::unknownMacroError(const Token *tok1) const
|
void Tokenizer::unknownMacroError(const Token *tok1) const
|
||||||
{
|
{
|
||||||
printDebugOutput(0);
|
printDebugOutput(0);
|
||||||
throw InternalError(tok1, "There is an unknown macro here somewhere. Configuration is required. If " + tok1->str() + " is a macro then please configure it.", InternalError::SYNTAX);
|
throw InternalError(tok1, "There is an unknown macro here somewhere. Configuration is required. If " + tok1->str() + " is a macro then please configure it.", InternalError::UNKNOWN_MACRO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tokenizer::unhandled_macro_class_x_y(const Token *tok) const
|
void Tokenizer::unhandled_macro_class_x_y(const Token *tok) const
|
||||||
|
|
Loading…
Reference in New Issue