Skip to content

Commit

Permalink
bump simplecpp
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Sep 12, 2017
1 parent 37dea8a commit 5c7cf58
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
16 changes: 15 additions & 1 deletion externals/simplecpp/simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ void simplecpp::TokenList::readfile(std::istream &istr, const std::string &filen
if (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')
ch = ' ';

if (ch >= 0x80) {
if (outputList) {
simplecpp::Output err(files);
err.type = simplecpp::Output::UNHANDLED_CHAR_ERROR;
err.location = location;
std::ostringstream s;
s << (int)ch;
err.msg = "The code contains unhandled character(s) (character code=" + s.str() + "). Neither unicode nor extended ascii is supported.";
outputList->push_back(err);
}
clear();
return;
}

if (ch == '\n') {
if (cback() && cback()->op == '\\') {
if (location.col > cback()->location.col + 1U)
Expand Down Expand Up @@ -1288,7 +1302,7 @@ namespace simplecpp {
if (!expandArg(tokens, tok, tok->location, macros, expandedmacros, parametertokens)) {
bool expanded = false;
const std::map<TokenString, Macro>::const_iterator it = macros.find(tok->str);
if (it != macros.end() && expandedmacros.find(tok->str) == expandedmacros.end()) {
if (it != macros.end() && expandedmacros.find(tok->str) == expandedmacros.end()) {
const Macro &m = it->second;
if (!m.functionLike()) {
m.expand(tokens, tok, macros, files);
Expand Down
3 changes: 2 additions & 1 deletion externals/simplecpp/simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ namespace simplecpp {
MISSING_HEADER,
INCLUDE_NESTED_TOO_DEEPLY,
SYNTAX_ERROR,
PORTABILITY_BACKSLASH
PORTABILITY_BACKSLASH,
UNHANDLED_CHAR_ERROR
} type;
Location location;
std::string msg;
Expand Down
43 changes: 29 additions & 14 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,35 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin

// If there is a syntax error, report it and stop
for (simplecpp::OutputList::const_iterator it = outputList.begin(); it != outputList.end(); ++it) {
if (it->type != simplecpp::Output::SYNTAX_ERROR)
continue;
const ErrorLogger::ErrorMessage::FileLocation loc1(it->location.file(), it->location.line);
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
callstack.push_back(loc1);

ErrorLogger::ErrorMessage errmsg(callstack,
"",
Severity::error,
it->msg,
"syntaxError",
false);
_errorLogger.reportErr(errmsg);
return 1;
bool err;
switch (it->type) {
case simplecpp::Output::ERROR:
case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY:
case simplecpp::Output::SYNTAX_ERROR:
case simplecpp::Output::UNHANDLED_CHAR_ERROR:
err = true;
break;
case simplecpp::Output::WARNING:
case simplecpp::Output::MISSING_HEADER:
case simplecpp::Output::PORTABILITY_BACKSLASH:
err = false;
break;
};

if (err) {
const ErrorLogger::ErrorMessage::FileLocation loc1(it->location.file(), it->location.line);
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
callstack.push_back(loc1);

ErrorLogger::ErrorMessage errmsg(callstack,
"",
Severity::error,
it->msg,
"syntaxError",
false);
_errorLogger.reportErr(errmsg);
return 1;
}
}

preprocessor.loadFiles(tokens1, files);
Expand Down
2 changes: 2 additions & 0 deletions lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ static bool hasErrors(const simplecpp::OutputList &outputList)
case simplecpp::Output::ERROR:
case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY:
case simplecpp::Output::SYNTAX_ERROR:
case simplecpp::Output::UNHANDLED_CHAR_ERROR:
return true;
case simplecpp::Output::WARNING:
case simplecpp::Output::MISSING_HEADER:
Expand Down Expand Up @@ -688,6 +689,7 @@ void Preprocessor::reportOutput(const simplecpp::OutputList &outputList, bool sh
break;
case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY:
case simplecpp::Output::SYNTAX_ERROR:
case simplecpp::Output::UNHANDLED_CHAR_ERROR:
error(it->location.file(), it->location.line, it->msg);
break;
};
Expand Down
2 changes: 1 addition & 1 deletion test/testastutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TestAstUtils : public TestFixture {
}

void isVariableChanged() {
// #8211 - no lhs for >> , do not crash
// #8211 - no lhs for >> , do not crash
ASSERT_EQUALS(true,
isVariableChanged("void f() {\n"
" int b;\n"
Expand Down

0 comments on commit 5c7cf58

Please sign in to comment.