Commit 58e89048 authored by Ivan Donchevskii's avatar Ivan Donchevskii

Clang: enable clang tidy and clazy in code model

Set QTC_CLANG_PLUGINS_LOAD env variable to get diagnostics
that come from libclang plugins.
This functionality works after the patch is applied to
clang repository and clang is properly built with it.

Task-number: QTCREATORBUG-15157
Change-Id: Iefeee4dd115f3f43ddc6ed79452a1135e653def6
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 7af341fe
This diff was suppressed by a .gitattributes entry.
......@@ -37,3 +37,10 @@ QTCREATORBUG-15449_Fix-files-lock-on-Windows.patch
Significantly reduces problems when saving a header file on Windows.
QTCREATORBUG-15157_Link-with-clazy.patch
https://bugreports.qt.io/browse/QTCREATORBUG-15157
Introduces the flag CLANG_ENABLE_CLAZY to link libclang with Clazy and
forces link for Clazy checks and plugin registry entry.
......@@ -79,6 +79,12 @@ static QString creatorResourcePath()
#endif
}
static bool loadClangPlugins()
{
static bool load = qEnvironmentVariableIntValue("QTC_CLANG_PLUGINS_LOAD");
return load;
}
class LibClangOptionsBuilder final : public CompilerOptionsBuilder
{
public:
......@@ -96,6 +102,10 @@ public:
void addExtraOptions() final
{
addDummyUiHeaderOnDiskIncludePath();
if (loadClangPlugins()) {
addTidyPlugin();
addClazyPlugin();
}
add("-fmessage-length=0");
add("-fdiagnostics-show-note-include-stack");
add("-fmacro-backtrace-limit=0");
......@@ -123,6 +133,26 @@ private:
if (!path.isEmpty())
add(includeDirOption() + QDir::toNativeSeparators(path));
}
void addClazyPlugin()
{
add("-Xclang");
add("-add-plugin");
add("-Xclang");
add("clang-lazy");
}
void addTidyPlugin()
{
add("-Xclang");
add("-add-plugin");
add("-Xclang");
add("clang-tidy");
add("-Xclang");
add("-plugin-arg-clang-tidy");
add("-Xclang");
add("-checks='-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming'");
}
};
/**
......
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