add "internalAstError" id so we can easily track ast errors on daca.
This commit is contained in:
parent
35736364f8
commit
58a64702b7
|
@ -37,6 +37,9 @@ InternalError::InternalError(const Token *tok, const std::string &errorMsg, Type
|
|||
token(tok), errorMessage(errorMsg)
|
||||
{
|
||||
switch (type) {
|
||||
case AST:
|
||||
id = "internalAstError";
|
||||
break;
|
||||
case SYNTAX:
|
||||
id = "syntaxError";
|
||||
break;
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace tinyxml2 {
|
|||
|
||||
/** @brief Simple container to be thrown when internal error is detected. */
|
||||
struct InternalError {
|
||||
enum Type {SYNTAX, INTERNAL};
|
||||
enum Type {AST, SYNTAX, INTERNAL};
|
||||
InternalError(const Token *tok, const std::string &errorMsg, Type type = INTERNAL);
|
||||
const Token *token;
|
||||
std::string errorMessage;
|
||||
|
|
|
@ -1128,11 +1128,11 @@ void TokenList::validateAst() const
|
|||
for (const Token *tok = _front; tok; tok = tok->next()) {
|
||||
// Syntax error if binary operator only has 1 operand
|
||||
if ((tok->isAssignmentOp() || tok->isComparisonOp() || Token::Match(tok,"[|^/%]")) && tok->astOperand1() && !tok->astOperand2())
|
||||
throw InternalError(tok, "Syntax Error: AST broken, binary operator has only one operand.", InternalError::SYNTAX);
|
||||
throw InternalError(tok, "Syntax Error: AST broken, binary operator has only one operand.", InternalError::AST);
|
||||
|
||||
// Syntax error if we encounter "?" with operand2 that is not ":"
|
||||
if (tok->astOperand2() && tok->str() == "?" && tok->astOperand2()->str() != ":")
|
||||
throw InternalError(tok, "Syntax Error: AST broken, ternary operator lacks ':'.", InternalError::SYNTAX);
|
||||
throw InternalError(tok, "Syntax Error: AST broken, ternary operator lacks ':'.", InternalError::AST);
|
||||
|
||||
// Check for endless recursion
|
||||
const Token* parent=tok->astParent();
|
||||
|
@ -1143,7 +1143,7 @@ void TokenList::validateAst() const
|
|||
if (safeAstTokens.find(parent) != safeAstTokens.end())
|
||||
break;
|
||||
if (astTokens.find(parent) != astTokens.end())
|
||||
throw InternalError(tok, "AST broken: endless recursion from '" + tok->str() + "'", InternalError::SYNTAX);
|
||||
throw InternalError(tok, "AST broken: endless recursion from '" + tok->str() + "'", InternalError::AST);
|
||||
astTokens.insert(parent);
|
||||
} while ((parent = parent->astParent()) != nullptr);
|
||||
safeAstTokens.insert(astTokens.begin(), astTokens.end());
|
||||
|
|
Loading…
Reference in New Issue