forked from qt-creator/qt-creator
Clang: Avoid warnings about unknown warning options
...as they are generated by e.g. Q_OBJECT use. Previously we have avoided Q_OBJECT warnings by using -Wno-unknown-pragmas (Qt Creator build with libclang 3.9). With the upgrade to libclang 5.0 GCC pragmas can now be parsed by clang and the related warning option thus changed to -Wunknown-warning-option. Note that previously -Wno-unknown-pragmas was part of every built-in configuration and visible in the UI. Now that option and the new one are added behind the scenes (not visible in the UI anymore) so that every diagnostic configuration, also the copied/customized ones, will profit from it. Still, by putting this hidden options first on the command line, the user can overwrite them with his own configuration if desired. Task-number: QTCREATORBUG-17460 Change-Id: I68aaec1b4791522bd8dc4e5fdb405cc5b9c9f514 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -439,6 +439,7 @@ public:
|
|||||||
, m_projectPart(projectPart)
|
, m_projectPart(projectPart)
|
||||||
{
|
{
|
||||||
addLanguageOptions();
|
addLanguageOptions();
|
||||||
|
addGlobalDiagnosticOptions(); // Before addDiagnosticOptions() so users still can overwrite.
|
||||||
addDiagnosticOptions();
|
addDiagnosticOptions();
|
||||||
addGlobalOptions();
|
addGlobalOptions();
|
||||||
addPrecompiledHeaderOptions();
|
addPrecompiledHeaderOptions();
|
||||||
@@ -519,6 +520,15 @@ private:
|
|||||||
addXclangArg("-plugin-arg-clang-lazy", checks);
|
addXclangArg("-plugin-arg-clang-lazy", checks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addGlobalDiagnosticOptions()
|
||||||
|
{
|
||||||
|
m_options.append({
|
||||||
|
// Avoid undesired warnings from e.g. Q_OBJECT
|
||||||
|
QStringLiteral("-Wno-unknown-pragmas"),
|
||||||
|
QStringLiteral("-Wno-unknown-warning-option")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void addGlobalOptions()
|
void addGlobalOptions()
|
||||||
{
|
{
|
||||||
if (!m_projectPart.project)
|
if (!m_projectPart.project)
|
||||||
|
@@ -33,11 +33,6 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
static QStringList commonWarnings()
|
|
||||||
{
|
|
||||||
return { QStringLiteral("-Wno-unknown-pragmas") };
|
|
||||||
}
|
|
||||||
|
|
||||||
static void addConfigForQuestionableConstructs(ClangDiagnosticConfigsModel &model)
|
static void addConfigForQuestionableConstructs(ClangDiagnosticConfigsModel &model)
|
||||||
{
|
{
|
||||||
ClangDiagnosticConfig config;
|
ClangDiagnosticConfig config;
|
||||||
@@ -48,7 +43,7 @@ static void addConfigForQuestionableConstructs(ClangDiagnosticConfigsModel &mode
|
|||||||
config.setClangOptions(QStringList{
|
config.setClangOptions(QStringList{
|
||||||
QStringLiteral("-Wall"),
|
QStringLiteral("-Wall"),
|
||||||
QStringLiteral("-Wextra"),
|
QStringLiteral("-Wextra"),
|
||||||
} + commonWarnings());
|
});
|
||||||
|
|
||||||
model.appendOrUpdate(config);
|
model.appendOrUpdate(config);
|
||||||
}
|
}
|
||||||
@@ -60,7 +55,7 @@ static void addConfigForPedanticWarnings(ClangDiagnosticConfigsModel &model)
|
|||||||
config.setDisplayName(QCoreApplication::translate("ClangDiagnosticConfigsModel",
|
config.setDisplayName(QCoreApplication::translate("ClangDiagnosticConfigsModel",
|
||||||
"Pedantic Warnings"));
|
"Pedantic Warnings"));
|
||||||
config.setIsReadOnly(true);
|
config.setIsReadOnly(true);
|
||||||
config.setClangOptions(QStringList{QStringLiteral("-Wpedantic")} + commonWarnings());
|
config.setClangOptions(QStringList{QStringLiteral("-Wpedantic")});
|
||||||
|
|
||||||
model.appendOrUpdate(config);
|
model.appendOrUpdate(config);
|
||||||
}
|
}
|
||||||
@@ -86,7 +81,7 @@ static void addConfigForAlmostEveryWarning(ClangDiagnosticConfigsModel &model)
|
|||||||
QStringLiteral("-Wno-switch-enum"),
|
QStringLiteral("-Wno-switch-enum"),
|
||||||
QStringLiteral("-Wno-missing-prototypes"), // Not optimal for C projects.
|
QStringLiteral("-Wno-missing-prototypes"), // Not optimal for C projects.
|
||||||
QStringLiteral("-Wno-used-but-marked-unused"), // e.g. QTest::qWait
|
QStringLiteral("-Wno-used-but-marked-unused"), // e.g. QTest::qWait
|
||||||
} + commonWarnings());
|
});
|
||||||
|
|
||||||
model.appendOrUpdate(config);
|
model.appendOrUpdate(config);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user