Clang import; If there are syntax errors then abort analysis
This commit is contained in:
parent
0eccffe8e3
commit
8ac2cdd9ff
|
@ -290,6 +290,45 @@ unsigned int CppCheck::check(const std::string &path)
|
||||||
std::cerr << "Failed to execute '" + cmd + "'" << std::endl;
|
std::cerr << "Failed to execute '" + cmd + "'" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure there are not syntax errors...
|
||||||
|
{
|
||||||
|
std::ifstream fin(stderr);
|
||||||
|
while (std::getline(fin, line)) {
|
||||||
|
if (line.find(": fatal error:") != std::string::npos) {
|
||||||
|
|
||||||
|
// file:line:column: error: ....
|
||||||
|
const std::string::size_type pos3 = line.find(": fatal error:");
|
||||||
|
const std::string::size_type pos2 = line.rfind(":", pos3 - 1);
|
||||||
|
const std::string::size_type pos1 = line.rfind(":", pos2 - 1);
|
||||||
|
|
||||||
|
if (pos1 >= pos2 || pos2 >= pos3)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const std::string filename = line.substr(0, pos1);
|
||||||
|
const std::string linenr = line.substr(pos1+1, pos2-pos1-1);
|
||||||
|
const std::string colnr = line.substr(pos2+1, pos3-pos2-1);
|
||||||
|
const std::string msg = line.substr(pos3 + 15);
|
||||||
|
|
||||||
|
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||||
|
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||||
|
loc.setfile(Path::toNativeSeparators(filename));
|
||||||
|
loc.line = std::atoi(linenr.c_str());
|
||||||
|
loc.column = std::atoi(colnr.c_str());
|
||||||
|
locationList.push_back(loc);
|
||||||
|
ErrorLogger::ErrorMessage errmsg(locationList,
|
||||||
|
loc.getfile(),
|
||||||
|
Severity::error,
|
||||||
|
msg,
|
||||||
|
"syntaxError",
|
||||||
|
false);
|
||||||
|
reportErr(errmsg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//std::cout << "Checking Clang ast dump:\n" << res.second << std::endl;
|
//std::cout << "Checking Clang ast dump:\n" << res.second << std::endl;
|
||||||
std::istringstream ast(res.second);
|
std::istringstream ast(res.second);
|
||||||
Tokenizer tokenizer(&mSettings, this);
|
Tokenizer tokenizer(&mSettings, this);
|
||||||
|
|
Loading…
Reference in New Issue