From 845427b74722ef7a57030ef1de713fb37c782737 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 27 Apr 2022 19:13:38 +0800 Subject: [PATCH] - fix: correctly parse link error message for clang --- NEWS.md | 1 + RedPandaIDE/compiler/compiler.cpp | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 8450cdb8..b214eca3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ Red Panda C++ Version 1.0.6 - 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 - 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 - enhancement: add autolink and project template for sqlite3 diff --git a/RedPandaIDE/compiler/compiler.cpp b/RedPandaIDE/compiler/compiler.cpp index 6b479b00..e82b5bb0 100644 --- a/RedPandaIDE/compiler/compiler.cpp +++ b/RedPandaIDE/compiler/compiler.cpp @@ -103,6 +103,8 @@ QString Compiler::getFileNameFromOutputLine(QString &line) { if (QFileInfo(temp).fileName() == QLatin1String("ld.exe")) { // skip ld.exe continue; + } else if (QFileInfo(temp).suffix()=="o") { // skip obj file + continue; } else { break; } @@ -122,6 +124,10 @@ int Compiler::getLineNumberFromOutputLine(QString &line) result = line.midRef(0,pos).toInt(); if (result > 0) line.remove(0,pos+1); + } else { + result = line.toInt(); + if (result > 0) + line=""; } return result; } @@ -195,6 +201,18 @@ void Compiler::processOutput(QString &line) } 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 = getLineNumberFromOutputLine(line); + emit compileIssue(mLastIssue); + mLastIssue.reset(); + return; + } QString inFilePrefix = QString("In file included from "); QString fromPrefix = QString("from "); PCompileIssue issue = std::make_shared(); @@ -270,7 +288,9 @@ void Compiler::processOutput(QString &line) issue->type = getIssueTypeFromOutputLine(line); } 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); } else mLastIssue = issue;