GUI: Fixed locations for clang/clang-tidy warnings

This commit is contained in:
Daniel Marjamäki 2017-08-10 22:46:23 +02:00
parent e909d8fe0d
commit 5de64d6755
2 changed files with 16 additions and 11 deletions

View File

@ -328,32 +328,34 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
{
QList<ErrorItem> errorItems;
ErrorItem errorItem;
QRegExp r1("(.+):([0-9]+):[0-9]+: (note|warning|error|fatal error): (.*)");
QRegExp r1("(.+):([0-9]+):([0-9]+): (note|warning|error|fatal error): (.*)");
QRegExp r2("(.*)\\[([a-zA-Z0-9\\-_\\.]+)\\]");
QTextStream in(&err, QIODevice::ReadOnly);
while (!in.atEnd()) {
QString line = in.readLine();
if (!r1.exactMatch(line))
continue;
if (r1.cap(3) != "note") {
if (r1.cap(4) != "note") {
errorItems.append(errorItem);
errorItem = ErrorItem();
errorItem.file0 = r1.cap(1);
}
errorItem.errorPath.append(QErrorPathItem());
errorItem.errorPath.last().file = r1.cap(1);
errorItem.errorPath.last().line = r1.cap(2).toInt();
if (r1.cap(3) == "warning")
errorItem.errorPath.last().col = r1.cap(3).toInt();
if (r1.cap(4) == "warning")
errorItem.severity = Severity::SeverityType::warning;
else if (r1.cap(3) == "error" || r1.cap(3) == "fatal error")
else if (r1.cap(4) == "error" || r1.cap(4) == "fatal error")
errorItem.severity = Severity::SeverityType::error;
QString message,id;
if (r2.exactMatch(r1.cap(4))) {
if (r2.exactMatch(r1.cap(5))) {
message = r2.cap(1);
id = tool + '-' + r2.cap(2);
} else {
message = r1.cap(4);
message = r1.cap(5);
id = CLANG;
}

View File

@ -128,7 +128,8 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
return false;
}
QString realfile = stripPath(item.errorPath.back().file, false);
const QErrorPathItem &loc = item.errorId.startsWith("clang") ? item.errorPath.front() : item.errorPath.back();
QString realfile = stripPath(loc.file, false);
if (realfile.isEmpty()) {
realfile = tr("Undefined file");
@ -153,7 +154,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
ErrorLine line;
line.file = realfile;
line.line = item.errorPath.back().line;
line.line = loc.line;
line.errorId = item.errorId;
line.inconclusive = item.inconclusive;
line.summary = item.summary;
@ -163,7 +164,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
line.tag = item.tag;
//Create the base item for the error and ensure it has a proper
//file item as a parent
QStandardItem* fileItem = ensureFileItem(item.errorPath.back().file, item.file0, hide);
QStandardItem* fileItem = ensureFileItem(loc.file, item.file0, hide);
QStandardItem* stditem = addBacktraceFiles(fileItem,
line,
hide,
@ -179,8 +180,9 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
data["severity"] = ShowTypes::SeverityToShowType(item.severity);
data["summary"] = item.summary;
data["message"] = item.message;
data["file"] = item.errorPath.back().file;
data["line"] = item.errorPath.back().line;
data["file"] = loc.file;
data["line"] = loc.line;
data["col"] = loc.col;
data["id"] = item.errorId;
data["inconclusive"] = item.inconclusive;
data["file0"] = stripPath(item.file0, true);
@ -211,6 +213,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
child_data["message"] = line.message;
child_data["file"] = e.file;
child_data["line"] = e.line;
child_data["col"] = e.col;
child_data["id"] = line.errorId;
child_data["inconclusive"] = line.inconclusive;
child_item->setData(QVariant(child_data));