Commit 1b0f87db authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Warn on some compiler flags that can mess up the output

For e.g., flto, fsanitize
parent b842ea4b
Pipeline #89333 passed with stage
in 2 minutes and 48 seconds
......@@ -42,6 +42,8 @@ public:
*/
explicit CEPluginView(CEPlugin *plugin, KTextEditor::MainWindow *mainwindow);
Q_SIGNAL void message(const QVariantMap &message);
/**
* Our Destructor
*/
......
#include "ce_widget.h"
#include "AsmView.h"
#include "AsmViewModel.h"
#include "ce_plugin.h"
#include "ce_service.h"
#include "compiledbreader.h"
......@@ -110,6 +111,8 @@ CEWidget::CEWidget(CEPluginView *pluginView, KTextEditor::MainWindow *mainWindow
QString args = CompileDBReader::filteredArgsForFile(compilecmds, file);
m_lineEdit->setText(args);
warnIfBadArgs(args.split(QLatin1Char(' ')));
setFocusPolicy(Qt::StrongFocus);
}
......@@ -182,7 +185,7 @@ bool CEWidget::eventFilter(QObject *o, QEvent *e)
return QWidget::eventFilter(o, e);
}
void CEWidget::createTopBar(class QVBoxLayout *mainLayout)
void CEWidget::createTopBar(QVBoxLayout *mainLayout)
{
QHBoxLayout *topBarLayout = new QHBoxLayout;
mainLayout->addLayout(topBarLayout);
......@@ -340,7 +343,7 @@ void CEWidget::initOptionsComboBox()
});
}
void CEWidget::createMainViews(class QVBoxLayout *mainLayout)
void CEWidget::createMainViews(QVBoxLayout *mainLayout)
{
if (!doc) {
return;
......@@ -561,3 +564,30 @@ void CEWidget::addExtraActionstoTextEditor()
menu->addActions(m->actions());
m_textEditor->setContextMenu(menu);
}
void CEWidget::sendMessage(const QString &plainText, bool warn)
{
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Error") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("CompilerExplorer"));
genericMessage.insert(QStringLiteral("text"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
}
void CEWidget::warnIfBadArgs(const QStringList &args)
{
QStringList warnableArgs = {QStringLiteral("flto"), QStringLiteral("fsanitize")};
QStringList found;
for (const auto &a : args) {
for (const auto &w : warnableArgs) {
if (a.contains(w)) {
warnableArgs.removeOne(w);
found.append(w);
}
}
}
QString msg = i18n("'%1' compiler flags were found. Output may not be useful.", found.join(QLatin1String(", ")));
sendMessage(msg, true);
}
......@@ -32,6 +32,8 @@ private:
void doCompile();
QString currentCompiler() const;
void addExtraActionstoTextEditor();
void warnIfBadArgs(const QStringList &args);
void sendMessage(const QString &plainText, bool warn);
void removeViewAsActiveXMLGuiClient();
void setViewAsActiveXMLGuiClient();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment