aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qbs/modules/libclang/functions.js34
-rw-r--r--qbs/modules/libclang/libclang.qbs2
-rw-r--r--src/plugins/clangformat/clangformat.pro2
-rw-r--r--src/plugins/clangformat/clangformatindenter.cpp7
-rw-r--r--src/shared/clang/clang_installation.pri14
5 files changed, 45 insertions, 14 deletions
diff --git a/qbs/modules/libclang/functions.js b/qbs/modules/libclang/functions.js
index 8533499260..bdffcc9c23 100644
--- a/qbs/modules/libclang/functions.js
+++ b/qbs/modules/libclang/functions.js
@@ -101,17 +101,33 @@ function extraLibraries(llvmConfig, targetOS)
}));
}
-function formattingLibs(llvmConfig, targetOS)
+function formattingLibs(llvmConfig, qtcFunctions, targetOS)
{
- var fixedList = [
- "clangFormat",
- "clangToolingCore",
- "clangRewrite",
- "clangLex",
- "clangBasic",
- ];
+ var clangVersion = version(llvmConfig)
+ var libs = []
+ if (qtcFunctions.versionIsAtLeast(clangVersion, MinimumLLVMVersion)) {
+ if (qtcFunctions.versionIsAtLeast(clangVersion, "7.0.0")) {
+ libs.concat([
+ "clangFormat",
+ "clangToolingInclusions",
+ "clangToolingCore",
+ "clangRewrite",
+ "clangLex",
+ "clangBasic",
+ ]);
+ } else {
+ libs.concat([
+ "clangFormat",
+ "clangToolingCore",
+ "clangRewrite",
+ "clangLex",
+ "clangBasic",
+ ]);
+ }
+ libs.concat(extraLibraries(llvmConfig, targetOS));
+ }
- return fixedList.concat(extraLibraries(llvmConfig, targetOS));
+ return libs;
}
function toolingLibs(llvmConfig, targetOS)
diff --git a/qbs/modules/libclang/libclang.qbs b/qbs/modules/libclang/libclang.qbs
index 1d695a2c8d..e95250ddba 100644
--- a/qbs/modules/libclang/libclang.qbs
+++ b/qbs/modules/libclang/libclang.qbs
@@ -38,7 +38,7 @@ Module {
llvmToolingDefines = toolingParams.defines;
llvmToolingIncludes = toolingParams.includes;
llvmToolingCxxFlags = toolingParams.cxxFlags;
- llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, targetOS);
+ llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, QtcFunctions, targetOS);
found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"));
}
}
diff --git a/src/plugins/clangformat/clangformat.pro b/src/plugins/clangformat/clangformat.pro
index 8657acb21b..c2e2edd49f 100644
--- a/src/plugins/clangformat/clangformat.pro
+++ b/src/plugins/clangformat/clangformat.pro
@@ -3,7 +3,7 @@ include(../../shared/clang/clang_installation.pri)
include(../../shared/clang/clang_defines.pri)
-requires(!isEmpty(LLVM_VERSION))
+requires(!isEmpty(CLANGFORMAT_LIBS))
win32 {
LLVM_BUILDMODE = $$system($$llvm_config --build-mode, lines)
diff --git a/src/plugins/clangformat/clangformatindenter.cpp b/src/plugins/clangformat/clangformatindenter.cpp
index f83cefb8ae..3164f4ad00 100644
--- a/src/plugins/clangformat/clangformatindenter.cpp
+++ b/src/plugins/clangformat/clangformatindenter.cpp
@@ -36,6 +36,8 @@
#include <utils/hostosinfo.h>
+#include <llvm/Config/llvm-config.h>
+
#include <QDir>
#include <QFileInfo>
#include <QTextBlock>
@@ -60,7 +62,12 @@ void adjustFormatStyleForLineBreak(format::FormatStyle &style,
if (length > 0)
style.ColumnLimit = prevBlockSize;
style.AlwaysBreakBeforeMultilineStrings = true;
+#if LLVM_VERSION_MAJOR >= 7
+ style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+#else
style.AlwaysBreakTemplateDeclarations = true;
+#endif
+
style.AllowAllParametersOfDeclarationOnNextLine = true;
style.AllowShortBlocksOnASingleLine = true;
style.AllowShortCaseLabelsOnASingleLine = true;
diff --git a/src/shared/clang/clang_installation.pri b/src/shared/clang/clang_installation.pri
index 863d29cf48..728cbb3ba4 100644
--- a/src/shared/clang/clang_installation.pri
+++ b/src/shared/clang/clang_installation.pri
@@ -116,9 +116,6 @@ CLANGTOOLING_LIBS=-lclangTooling -lclangIndex -lclangFrontend -lclangParse -lcla
-lclangASTMatchers -lclangToolingCore -lclangAST -lclangLex -lclangBasic
win32:CLANGTOOLING_LIBS += -lversion
-CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
-win32:CLANGFORMAT_LIBS += -lversion
-
BIN_EXTENSION =
win32: BIN_EXTENSION = .exe
@@ -141,6 +138,17 @@ isEmpty(LLVM_INSTALL_DIR) {
output = $$system($$llvm_config --version, lines)
LLVM_VERSION = $$extractVersion($$output)
+
+!isEmpty(LLVM_VERSION) {
+ versionIsAtLeast($$LLVM_VERSION, 7, 0, 0): {
+ CLANGFORMAT_LIBS=-lclangFormat -lclangToolingInclusions -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
+ win32:CLANGFORMAT_LIBS += -lversion
+ } else:versionIsAtLeast($$LLVM_VERSION, 6, 0, 0): {
+ CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
+ win32:CLANGFORMAT_LIBS += -lversion
+ }
+}
+
isEmpty(LLVM_VERSION) {
$$llvmWarningOrError(\
"Cannot determine clang version. Set LLVM_INSTALL_DIR to build the Clang Code Model",\