forked from qt-creator/qt-creator
Clang: Fix ClangFormat build with clang-7
Change-Id: I0859b7aad1a49f8d46ee4b32cc32039cfa0b482b Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -101,17 +101,33 @@ function extraLibraries(llvmConfig, targetOS)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function formattingLibs(llvmConfig, targetOS)
|
function formattingLibs(llvmConfig, qtcFunctions, targetOS)
|
||||||
{
|
{
|
||||||
var fixedList = [
|
var clangVersion = version(llvmConfig)
|
||||||
"clangFormat",
|
var libs = []
|
||||||
"clangToolingCore",
|
if (qtcFunctions.versionIsAtLeast(clangVersion, MinimumLLVMVersion)) {
|
||||||
"clangRewrite",
|
if (qtcFunctions.versionIsAtLeast(clangVersion, "7.0.0")) {
|
||||||
"clangLex",
|
libs.concat([
|
||||||
"clangBasic",
|
"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)
|
function toolingLibs(llvmConfig, targetOS)
|
||||||
|
@@ -38,7 +38,7 @@ Module {
|
|||||||
llvmToolingDefines = toolingParams.defines;
|
llvmToolingDefines = toolingParams.defines;
|
||||||
llvmToolingIncludes = toolingParams.includes;
|
llvmToolingIncludes = toolingParams.includes;
|
||||||
llvmToolingCxxFlags = toolingParams.cxxFlags;
|
llvmToolingCxxFlags = toolingParams.cxxFlags;
|
||||||
llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, targetOS);
|
llvmFormattingLibs = ClangFunctions.formattingLibs(llvmConfig, QtcFunctions, targetOS);
|
||||||
found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"));
|
found = llvmConfig && File.exists(llvmIncludeDir.concat("/clang-c/Index.h"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ include(../../shared/clang/clang_installation.pri)
|
|||||||
|
|
||||||
include(../../shared/clang/clang_defines.pri)
|
include(../../shared/clang/clang_defines.pri)
|
||||||
|
|
||||||
requires(!isEmpty(LLVM_VERSION))
|
requires(!isEmpty(CLANGFORMAT_LIBS))
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
LLVM_BUILDMODE = $$system($$llvm_config --build-mode, lines)
|
LLVM_BUILDMODE = $$system($$llvm_config --build-mode, lines)
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
|
||||||
|
#include <llvm/Config/llvm-config.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
@@ -60,7 +62,12 @@ void adjustFormatStyleForLineBreak(format::FormatStyle &style,
|
|||||||
if (length > 0)
|
if (length > 0)
|
||||||
style.ColumnLimit = prevBlockSize;
|
style.ColumnLimit = prevBlockSize;
|
||||||
style.AlwaysBreakBeforeMultilineStrings = true;
|
style.AlwaysBreakBeforeMultilineStrings = true;
|
||||||
|
#if LLVM_VERSION_MAJOR >= 7
|
||||||
|
style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
|
||||||
|
#else
|
||||||
style.AlwaysBreakTemplateDeclarations = true;
|
style.AlwaysBreakTemplateDeclarations = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
style.AllowAllParametersOfDeclarationOnNextLine = true;
|
style.AllowAllParametersOfDeclarationOnNextLine = true;
|
||||||
style.AllowShortBlocksOnASingleLine = true;
|
style.AllowShortBlocksOnASingleLine = true;
|
||||||
style.AllowShortCaseLabelsOnASingleLine = true;
|
style.AllowShortCaseLabelsOnASingleLine = true;
|
||||||
|
@@ -116,9 +116,6 @@ CLANGTOOLING_LIBS=-lclangTooling -lclangIndex -lclangFrontend -lclangParse -lcla
|
|||||||
-lclangASTMatchers -lclangToolingCore -lclangAST -lclangLex -lclangBasic
|
-lclangASTMatchers -lclangToolingCore -lclangAST -lclangLex -lclangBasic
|
||||||
win32:CLANGTOOLING_LIBS += -lversion
|
win32:CLANGTOOLING_LIBS += -lversion
|
||||||
|
|
||||||
CLANGFORMAT_LIBS=-lclangFormat -lclangToolingCore -lclangRewrite -lclangLex -lclangBasic
|
|
||||||
win32:CLANGFORMAT_LIBS += -lversion
|
|
||||||
|
|
||||||
BIN_EXTENSION =
|
BIN_EXTENSION =
|
||||||
win32: BIN_EXTENSION = .exe
|
win32: BIN_EXTENSION = .exe
|
||||||
|
|
||||||
@@ -141,6 +138,17 @@ isEmpty(LLVM_INSTALL_DIR) {
|
|||||||
|
|
||||||
output = $$system($$llvm_config --version, lines)
|
output = $$system($$llvm_config --version, lines)
|
||||||
LLVM_VERSION = $$extractVersion($$output)
|
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) {
|
isEmpty(LLVM_VERSION) {
|
||||||
$$llvmWarningOrError(\
|
$$llvmWarningOrError(\
|
||||||
"Cannot determine clang version. Set LLVM_INSTALL_DIR to build the Clang Code Model",\
|
"Cannot determine clang version. Set LLVM_INSTALL_DIR to build the Clang Code Model",\
|
||||||
|
Reference in New Issue
Block a user