- fix: Filename in the gcc 13.1 error messages when building project is using wrong encoding.

This commit is contained in:
Roy Qu 2023-08-08 12:44:46 +08:00
parent f111433ac5
commit dfbdf604fb
5 changed files with 70 additions and 40 deletions

View File

@ -17,7 +17,7 @@ Red Panda C++ Version 2.24
- fix: Accessibilty for inherited members are not correct calculated in multiple inheritance.
- fix: Can't parse full class name when handle inheritance.
- fix: Can't parse virtual inherit.
- fix: Filename in the gcc 13.1 error messages when building project is using wrong encoding.
Red Panda C++ Version 2.23

View File

@ -664,6 +664,8 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
bool errorOccurred = false;
process.setProgram(cmd);
QString cmdDir = extractFileDir(cmd);
bool compilerErrorUTF8=compilerSet()->isCompilerInfoUsingUTF8();
bool outputUTF8=compilerSet()->forceUTF8();
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
if (!cmdDir.isEmpty()) {
QString path = env.value("PATH");
@ -682,18 +684,19 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
process.setArguments(splitProcessCommand(arguments));
process.setWorkingDirectory(workingDir);
process.connect(&process, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
process.connect(&process, &QProcess::readyReadStandardError,[&process,this](){
if (compilerSet()->compilerType() == CompilerType::Clang)
process.connect(&process, &QProcess::readyReadStandardError,[&process,this,compilerErrorUTF8](){
if (compilerErrorUTF8)
this->error(QString::fromUtf8(process.readAllStandardError()));
else
this->error(QString::fromLocal8Bit( process.readAllStandardError()));
});
process.connect(&process, &QProcess::readyReadStandardOutput,[&process,this](){
if (compilerSet()->compilerType() == CompilerType::Clang)
process.connect(&process, &QProcess::readyReadStandardOutput,[&process,this,outputUTF8](){
if (outputUTF8)
this->log(QString::fromUtf8(process.readAllStandardOutput()));
else
this->log(QString::fromLocal8Bit( process.readAllStandardOutput()));

View File

@ -84,28 +84,8 @@ bool Debugger::start(int compilerSetIndex, const QString& inferior, const QStrin
tr("No compiler set is configured.")+tr("Can't start debugging."));
return false;
}
setForceUTF8(CompilerInfoManager::forceUTF8InDebugger(compilerSet->compilerType()));
setDebugInfosUsingUTF8(false);
#ifdef Q_OS_WIN
bool isOk;
int productVersion = QSysInfo::productVersion().toInt(&isOk);
// qDebug()<<productVersion<<isOk;
if (!isOk) {
if (QSysInfo::productVersion().startsWith("7"))
productVersion=7;
else if (QSysInfo::productVersion().startsWith("10"))
productVersion=10;
else if (QSysInfo::productVersion().startsWith("11"))
productVersion=11;
else
productVersion=10;
}
if (compilerSet->mainVersion()>=13 && compilerSet->compilerType()==CompilerType::GCC
&& productVersion>=10)
setDebugInfosUsingUTF8(true);
#endif
setForceUTF8(compilerSet->forceUTF8());
setDebugInfosUsingUTF8(compilerSet->isDebugInfoUsingUTF8());
if (compilerSet->debugger().endsWith(LLDB_MI_PROGRAM))
setDebuggerType(DebuggerType::LLDB_MI);
else

View File

@ -1794,7 +1794,7 @@ void Settings::CompilerSet::setCompileOptions(const QMap<QString, QString> optio
mCompileOptions=options;
}
QString Settings::CompilerSet::getCompileOptionValue(const QString &key)
QString Settings::CompilerSet::getCompileOptionValue(const QString &key) const
{
return mCompileOptions.value(key,QString());
}
@ -2485,7 +2485,7 @@ void Settings::CompilerSet::setDirectories(const QString& binDir,CompilerType co
}
}
int Settings::CompilerSet::mainVersion()
int Settings::CompilerSet::mainVersion() const
{
int i = mVersion.indexOf('.');
if (i<0)
@ -2498,22 +2498,22 @@ int Settings::CompilerSet::mainVersion()
}
bool Settings::CompilerSet::canCompileC()
bool Settings::CompilerSet::canCompileC() const
{
return fileExists(mCCompiler);
}
bool Settings::CompilerSet::canCompileCPP()
bool Settings::CompilerSet::canCompileCPP() const
{
return fileExists(mCppCompiler);
}
bool Settings::CompilerSet::canMake()
bool Settings::CompilerSet::canMake() const
{
return fileExists(mMake);
}
bool Settings::CompilerSet::canDebug()
bool Settings::CompilerSet::canDebug() const
{
return fileExists(mDebugger);
}
@ -2603,6 +2603,49 @@ bool Settings::CompilerSet::isOutputExecutable(CompilationStage stage)
return stage == CompilationStage::GenerateExecutable;
}
bool Settings::CompilerSet::isDebugInfoUsingUTF8() const
{
switch(mCompilerType) {
case CompilerType::Clang:
case CompilerType::GCC_UTF8:
return true;
case CompilerType::GCC:
#ifdef Q_OS_WIN
if (mainVersion()>=13) {
bool isOk;
int productVersion = QSysInfo::productVersion().toInt(&isOk);
// qDebug()<<productVersion<<isOk;
if (!isOk) {
if (QSysInfo::productVersion().startsWith("7"))
productVersion=7;
else if (QSysInfo::productVersion().startsWith("10"))
productVersion=10;
else if (QSysInfo::productVersion().startsWith("11"))
productVersion=11;
else
productVersion=10;
}
return productVersion>=10;
}
#else
break;
#endif
default:
break;
}
return false;
}
bool Settings::CompilerSet::forceUTF8() const
{
return CompilerInfoManager::forceUTF8InDebugger(mCompilerType);
}
bool Settings::CompilerSet::isCompilerInfoUsingUTF8() const
{
return isDebugInfoUsingUTF8();
}
const QString &Settings::CompilerSet::assemblingSuffix() const
{
return mAssemblingSuffix;

View File

@ -1342,14 +1342,14 @@ public:
void unsetCompileOption(const QString& key);
void setCompileOptions(const QMap<QString, QString> options);
QString getCompileOptionValue(const QString& key);
QString getCompileOptionValue(const QString& key) const;
int mainVersion();
int mainVersion() const;
bool canCompileC();
bool canCompileCPP();
bool canMake();
bool canDebug();
bool canCompileC() const;
bool canCompileCPP() const;
bool canMake() const;
bool canDebug() const;
// bool dirsValid(QString& msg);
// bool validateExes(QString& msg);
//properties
@ -1435,6 +1435,10 @@ public:
bool isOutputExecutable();
bool isOutputExecutable(Settings::CompilerSet::CompilationStage stage);
bool isDebugInfoUsingUTF8() const;
bool forceUTF8() const;
bool isCompilerInfoUsingUTF8() const;
private:
void setDirectories(const QString& binDir, CompilerType mCompilerType);
//load hard defines