- fix: correctly parse link error message for clang

This commit is contained in:
Roy Qu 2022-04-27 19:13:38 +08:00
parent 945ba4ce73
commit 845427b747
2 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,7 @@ Red Panda C++ Version 1.0.6
- enhancement: package script for msys2 clang - enhancement: package script for msys2 clang
- enhancement: auto set problem case's expected output file which has "ans" as the suffix, when batch set cases - enhancement: auto set problem case's expected output file which has "ans" as the suffix, when batch set cases
- fix: use utf8 as the encoding for clang's error output - fix: use utf8 as the encoding for clang's error output
- fix: correctly parse link error message for clang
Red Panda C++ Version 1.0.5 Red Panda C++ Version 1.0.5
- enhancement: add autolink and project template for sqlite3 - enhancement: add autolink and project template for sqlite3

View File

@ -103,6 +103,8 @@ QString Compiler::getFileNameFromOutputLine(QString &line) {
if (QFileInfo(temp).fileName() == QLatin1String("ld.exe")) { // skip ld.exe if (QFileInfo(temp).fileName() == QLatin1String("ld.exe")) { // skip ld.exe
continue; continue;
} else if (QFileInfo(temp).suffix()=="o") { // skip obj file
continue;
} else { } else {
break; break;
} }
@ -122,6 +124,10 @@ int Compiler::getLineNumberFromOutputLine(QString &line)
result = line.midRef(0,pos).toInt(); result = line.midRef(0,pos).toInt();
if (result > 0) if (result > 0)
line.remove(0,pos+1); line.remove(0,pos+1);
} else {
result = line.toInt();
if (result > 0)
line="";
} }
return result; return result;
} }
@ -195,6 +201,18 @@ void Compiler::processOutput(QString &line)
} }
return; return;
} }
if (line.startsWith(">>>"))
line.remove(0,3);
QString referencePrefix = QString(" referenced by ");
if(mLastIssue && line.startsWith(referencePrefix)) {
line.remove(0,referencePrefix.length());
mLastIssue->filename = getFileNameFromOutputLine(line);
qDebug()<<line;
mLastIssue->line = getLineNumberFromOutputLine(line);
emit compileIssue(mLastIssue);
mLastIssue.reset();
return;
}
QString inFilePrefix = QString("In file included from "); QString inFilePrefix = QString("In file included from ");
QString fromPrefix = QString("from "); QString fromPrefix = QString("from ");
PCompileIssue issue = std::make_shared<CompileIssue>(); PCompileIssue issue = std::make_shared<CompileIssue>();
@ -270,7 +288,9 @@ void Compiler::processOutput(QString &line)
issue->type = getIssueTypeFromOutputLine(line); issue->type = getIssueTypeFromOutputLine(line);
} }
issue->description = line.trimmed(); issue->description = line.trimmed();
if (issue->line<=0) { if (issue->line<=0 && (issue->filename=="ld" || issue->filename=="lld")) {
mLastIssue = issue;
} else if (issue->line<=0) {
emit compileIssue(issue); emit compileIssue(issue);
} else } else
mLastIssue = issue; mLastIssue = issue;