summaryrefslogtreecommitdiff
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-01-28 22:10:23 +0100
committerBrad King <brad.king@kitware.com>2016-08-25 09:47:26 -0400
commit33bb9cfa365f494bb76ff9c2c78ad625e77152ec (patch)
tree0fcee76ccbd93a5d2a8cc07ac0919a351642b358 /Source/cmListFileCache.cxx
parentdb7de303c2a1e35b672016833db4bf85148c98c2 (diff)
downloadcmake-33bb9cfa365f494bb76ff9c2c78ad625e77152ec.tar.gz
Parser: Issue messages through cmake, not cmSystemTools
Make these messages uniform with regard to other messages issued by cmake.
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx70
1 files changed, 40 insertions, 30 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 1a2ddaff48..9204d14800 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -24,6 +24,7 @@ struct cmListFileParser
cmListFileParser(cmListFile* lf, cmMakefile* mf, const char* filename);
~cmListFileParser();
void IssueFileOpenError(std::string const& text) const;
+ void IssueError(std::string const& text) const;
bool ParseFile();
bool ParseFunction(const char* name, long line);
bool AddArgument(cmListFileLexer_Token* token,
@@ -62,6 +63,18 @@ void cmListFileParser::IssueFileOpenError(const std::string& text) const
this->Makefile->IssueMessage(cmake::FATAL_ERROR, text);
}
+void cmListFileParser::IssueError(const std::string& text) const
+{
+ cmListFileContext lfc;
+ lfc.FilePath = this->FileName;
+ lfc.Line = cmListFileLexer_GetCurrentLine(this->Lexer);
+ cmListFileBacktrace lfbt = this->Backtrace;
+ lfbt = lfbt.Push(lfc);
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, text,
+ lfbt);
+ cmSystemTools::SetFatalErrorOccured();
+}
+
bool cmListFileParser::ParseFile()
{
// Open the file.
@@ -98,22 +111,18 @@ bool cmListFileParser::ParseFile()
}
} else {
std::ostringstream error;
- error << "Error in cmake code at\n"
- << this->FileName << ":" << token->line << ":\n"
- << "Parse error. Expected a newline, got "
+ error << "Parse error. Expected a newline, got "
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
- cmSystemTools::Error(error.str().c_str());
+ this->IssueError(error.str());
return false;
}
} else {
std::ostringstream error;
- error << "Error in cmake code at\n"
- << this->FileName << ":" << token->line << ":\n"
- << "Parse error. Expected a command name, got "
+ error << "Parse error. Expected a command name, got "
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
- cmSystemTools::Error(error.str().c_str());
+ this->IssueError(error.str());
return false;
}
}
@@ -156,18 +165,15 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Function missing opening \"(\".";
/* clang-format on */
- cmSystemTools::Error(error.str().c_str());
+ this->IssueError(error.str());
return false;
}
if (token->type != cmListFileLexer_Token_ParenLeft) {
std::ostringstream error;
- error << "Error in cmake code at\n"
- << this->FileName << ":"
- << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
- << "Parse error. Expected \"(\", got "
+ error << "Parse error. Expected \"(\", got "
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
- cmSystemTools::Error(error.str().c_str());
+ this->IssueError(error.str());
return false;
}
@@ -219,25 +225,25 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
} else {
// Error.
std::ostringstream error;
- error << "Error in cmake code at\n"
- << this->FileName << ":"
- << cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
- << "Parse error. Function missing ending \")\". "
+ error << "Parse error. Function missing ending \")\". "
<< "Instead found "
<< cmListFileLexer_GetTypeAsString(this->Lexer, token->type)
<< " with text \"" << token->text << "\".";
- cmSystemTools::Error(error.str().c_str());
+ this->IssueError(error.str());
return false;
}
}
std::ostringstream error;
- error << "Error in cmake code at\n"
- << this->FileName << ":" << lastLine << ":\n"
- << "Parse error. Function missing ending \")\". "
+ cmListFileContext lfc;
+ lfc.FilePath = this->FileName;
+ lfc.Line = lastLine;
+ cmListFileBacktrace lfbt = this->Backtrace;
+ lfbt = lfbt.Push(lfc);
+ error << "Parse error. Function missing ending \")\". "
<< "End of file reached.";
- cmSystemTools::Error(error.str().c_str());
-
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
+ error.str(), lfbt);
return false;
}
@@ -252,17 +258,21 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
bool isError = (this->Separation == SeparationError ||
delim == cmListFileArgument::Bracket);
std::ostringstream m;
- /* clang-format off */
- m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
- << " " << this->FileName << ":" << token->line << ":"
- << token->column << "\n"
+ cmListFileContext lfc;
+ lfc.FilePath = this->FileName;
+ lfc.Line = token->line;
+ cmListFileBacktrace lfbt = this->Backtrace;
+ lfbt = lfbt.Push(lfc);
+
+ m << "Syntax " << (isError ? "Error" : "Warning") << " in cmake code at "
+ << "column " << token->column << "\n"
<< "Argument not separated from preceding token by whitespace.";
/* clang-format on */
if (isError) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, m.str(), lfbt);
return false;
}
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(), lfbt);
return true;
}