forked from qt-creator/qt-creator
Raise minimum supported libclang
ClangFormat needs 14.0+ nowadays. Change-Id: Ib5e38c79c5ec629fed4e5d8da5435769a71b2626 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -44,11 +44,11 @@ Prerequisites:
|
|||||||
* Qt WebEngine module for QtWebEngine based help viewer
|
* Qt WebEngine module for QtWebEngine based help viewer
|
||||||
* On Windows:
|
* On Windows:
|
||||||
* MinGW with GCC 9 or Visual Studio 2019 or later
|
* MinGW with GCC 9 or Visual Studio 2019 or later
|
||||||
* Python 3.5 or later (optional, needed for the python enabled debug helper)
|
* Python 3.8 or later (optional, needed for the python enabled debug helper)
|
||||||
* Debugging Tools for Windows (optional, for MSVC debugging support with CDB)
|
* Debugging Tools for Windows (optional, for MSVC debugging support with CDB)
|
||||||
* On Mac OS X: latest Xcode
|
* On Mac OS X: latest Xcode
|
||||||
* On Linux: GCC 9 or later
|
* On Linux: GCC 9 or later
|
||||||
* LLVM/Clang 10 or later (optional, LLVM/Clang 14 is recommended.
|
* LLVM/Clang 14 or later (optional, LLVM/Clang 17 is recommended.
|
||||||
See [instructions](#getting-llvmclang-for-the-clang-code-model) on how to
|
See [instructions](#getting-llvmclang-for-the-clang-code-model) on how to
|
||||||
get LLVM.
|
get LLVM.
|
||||||
The ClangFormat plugin uses the LLVM C++ API.
|
The ClangFormat plugin uses the LLVM C++ API.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
var Environment = require("qbs.Environment")
|
var Environment = require("qbs.Environment")
|
||||||
var File = require("qbs.File")
|
var File = require("qbs.File")
|
||||||
var FileInfo = require("qbs.FileInfo")
|
var FileInfo = require("qbs.FileInfo")
|
||||||
var MinimumLLVMVersion = "8.0.0" // CLANG-UPGRADE-CHECK: Adapt minimum version numbers.
|
var MinimumLLVMVersion = "14.0.0" // CLANG-UPGRADE-CHECK: Adapt minimum version numbers.
|
||||||
var Process = require("qbs.Process")
|
var Process = require("qbs.Process")
|
||||||
var Utilities = require("qbs.Utilities")
|
var Utilities = require("qbs.Utilities")
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
add_qtc_plugin(ClangFormat
|
add_qtc_plugin(ClangFormat
|
||||||
CONDITION TARGET ${CLANG_FORMAT_LIB} AND LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 10.0.0 AND (QTC_CLANG_BUILDMODE_MATCH OR CLANGTOOLING_LINK_CLANG_DYLIB)
|
CONDITION TARGET ${CLANG_FORMAT_LIB} AND LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL 14.0.0 AND (QTC_CLANG_BUILDMODE_MATCH OR CLANGTOOLING_LINK_CLANG_DYLIB)
|
||||||
DEPENDS Utils Qt::Widgets ${CLANG_FORMAT_LIB}
|
DEPENDS Utils Qt::Widgets ${CLANG_FORMAT_LIB}
|
||||||
PLUGIN_DEPENDS Core TextEditor CppEditor ProjectExplorer
|
PLUGIN_DEPENDS Core TextEditor CppEditor ProjectExplorer
|
||||||
SOURCES
|
SOURCES
|
||||||
|
|||||||
@@ -42,11 +42,7 @@ static void adjustFormatStyleForLineBreak(clang::format::FormatStyle &style,
|
|||||||
ReplacementsToKeep replacementsToKeep)
|
ReplacementsToKeep replacementsToKeep)
|
||||||
{
|
{
|
||||||
style.MaxEmptyLinesToKeep = 100;
|
style.MaxEmptyLinesToKeep = 100;
|
||||||
#if LLVM_VERSION_MAJOR >= 13
|
|
||||||
style.SortIncludes = clang::format::FormatStyle::SI_Never;
|
style.SortIncludes = clang::format::FormatStyle::SI_Never;
|
||||||
#else
|
|
||||||
style.SortIncludes = false;
|
|
||||||
#endif
|
|
||||||
#if LLVM_VERSION_MAJOR >= 16
|
#if LLVM_VERSION_MAJOR >= 16
|
||||||
style.SortUsingDeclarations = clang::format::FormatStyle::SUD_Never;
|
style.SortUsingDeclarations = clang::format::FormatStyle::SUD_Never;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -42,37 +42,22 @@ clang::format::FormatStyle calculateQtcStyle()
|
|||||||
#if LLVM_VERSION_MAJOR >= 15
|
#if LLVM_VERSION_MAJOR >= 15
|
||||||
style.AlignConsecutiveAssignments = {false, false, false, false, false};
|
style.AlignConsecutiveAssignments = {false, false, false, false, false};
|
||||||
style.AlignConsecutiveDeclarations = {false, false, false, false, false};
|
style.AlignConsecutiveDeclarations = {false, false, false, false, false};
|
||||||
#elif LLVM_VERSION_MAJOR >= 12
|
#else
|
||||||
style.AlignConsecutiveAssignments = FormatStyle::ACS_None;
|
style.AlignConsecutiveAssignments = FormatStyle::ACS_None;
|
||||||
style.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
|
style.AlignConsecutiveDeclarations = FormatStyle::ACS_None;
|
||||||
#else
|
|
||||||
style.AlignConsecutiveAssignments = false;
|
|
||||||
style.AlignConsecutiveDeclarations = false;
|
|
||||||
#endif
|
#endif
|
||||||
style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
|
style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
|
||||||
#if LLVM_VERSION_MAJOR >= 11
|
|
||||||
style.AlignOperands = FormatStyle::OAS_Align;
|
style.AlignOperands = FormatStyle::OAS_Align;
|
||||||
#else
|
|
||||||
style.AlignOperands = true;
|
|
||||||
#endif
|
|
||||||
#if LLVM_VERSION_MAJOR >= 16
|
#if LLVM_VERSION_MAJOR >= 16
|
||||||
style.AlignTrailingComments = {FormatStyle::TCAS_Always, 0};
|
style.AlignTrailingComments = {FormatStyle::TCAS_Always, 0};
|
||||||
#else
|
#else
|
||||||
style.AlignTrailingComments = true;
|
style.AlignTrailingComments = true;
|
||||||
#endif
|
#endif
|
||||||
style.AllowAllParametersOfDeclarationOnNextLine = true;
|
style.AllowAllParametersOfDeclarationOnNextLine = true;
|
||||||
#if LLVM_VERSION_MAJOR >= 10
|
|
||||||
style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
|
style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
|
||||||
#else
|
|
||||||
style.AllowShortBlocksOnASingleLine = false;
|
|
||||||
#endif
|
|
||||||
style.AllowShortCaseLabelsOnASingleLine = false;
|
style.AllowShortCaseLabelsOnASingleLine = false;
|
||||||
style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
|
style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
|
||||||
#if LLVM_VERSION_MAJOR >= 9
|
|
||||||
style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
|
style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
|
||||||
#else
|
|
||||||
style.AllowShortIfStatementsOnASingleLine = false;
|
|
||||||
#endif
|
|
||||||
style.AllowShortLoopsOnASingleLine = false;
|
style.AllowShortLoopsOnASingleLine = false;
|
||||||
style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
|
style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
|
||||||
style.AlwaysBreakBeforeMultilineStrings = false;
|
style.AlwaysBreakBeforeMultilineStrings = false;
|
||||||
@@ -80,11 +65,7 @@ clang::format::FormatStyle calculateQtcStyle()
|
|||||||
style.BinPackArguments = false;
|
style.BinPackArguments = false;
|
||||||
style.BinPackParameters = false;
|
style.BinPackParameters = false;
|
||||||
style.BraceWrapping.AfterClass = true;
|
style.BraceWrapping.AfterClass = true;
|
||||||
#if LLVM_VERSION_MAJOR >= 10
|
|
||||||
style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
|
style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Never;
|
||||||
#else
|
|
||||||
style.BraceWrapping.AfterControlStatement = false;
|
|
||||||
#endif
|
|
||||||
style.BraceWrapping.AfterEnum = false;
|
style.BraceWrapping.AfterEnum = false;
|
||||||
style.BraceWrapping.AfterFunction = true;
|
style.BraceWrapping.AfterFunction = true;
|
||||||
style.BraceWrapping.AfterNamespace = false;
|
style.BraceWrapping.AfterNamespace = false;
|
||||||
@@ -119,11 +100,7 @@ clang::format::FormatStyle calculateQtcStyle()
|
|||||||
style.ExperimentalAutoDetectBinPacking = false;
|
style.ExperimentalAutoDetectBinPacking = false;
|
||||||
style.FixNamespaceComments = true;
|
style.FixNamespaceComments = true;
|
||||||
style.ForEachMacros = {"forever", "foreach", "Q_FOREACH", "BOOST_FOREACH"};
|
style.ForEachMacros = {"forever", "foreach", "Q_FOREACH", "BOOST_FOREACH"};
|
||||||
#if LLVM_VERSION_MAJOR >= 12
|
|
||||||
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200, 200, true}};
|
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200, 200, true}};
|
||||||
#else
|
|
||||||
style.IncludeStyle.IncludeCategories = {{"^<Q.*", 200, 200}};
|
|
||||||
#endif
|
|
||||||
style.IncludeStyle.IncludeIsMainRegex = "(Test)?$";
|
style.IncludeStyle.IncludeIsMainRegex = "(Test)?$";
|
||||||
style.IndentCaseLabels = false;
|
style.IndentCaseLabels = false;
|
||||||
style.IndentWidth = 4;
|
style.IndentWidth = 4;
|
||||||
@@ -148,11 +125,7 @@ clang::format::FormatStyle calculateQtcStyle()
|
|||||||
style.PenaltyReturnTypeOnItsOwnLine = 300;
|
style.PenaltyReturnTypeOnItsOwnLine = 300;
|
||||||
style.PointerAlignment = FormatStyle::PAS_Right;
|
style.PointerAlignment = FormatStyle::PAS_Right;
|
||||||
style.ReflowComments = false;
|
style.ReflowComments = false;
|
||||||
#if LLVM_VERSION_MAJOR >= 13
|
|
||||||
style.SortIncludes = FormatStyle::SI_CaseSensitive;
|
style.SortIncludes = FormatStyle::SI_CaseSensitive;
|
||||||
#else
|
|
||||||
style.SortIncludes = true;
|
|
||||||
#endif
|
|
||||||
#if LLVM_VERSION_MAJOR >= 16
|
#if LLVM_VERSION_MAJOR >= 16
|
||||||
style.SortUsingDeclarations = FormatStyle::SUD_Lexicographic;
|
style.SortUsingDeclarations = FormatStyle::SUD_Lexicographic;
|
||||||
#else
|
#else
|
||||||
@@ -166,11 +139,7 @@ clang::format::FormatStyle calculateQtcStyle()
|
|||||||
style.SpaceInEmptyParentheses = false;
|
style.SpaceInEmptyParentheses = false;
|
||||||
#endif
|
#endif
|
||||||
style.SpacesBeforeTrailingComments = 1;
|
style.SpacesBeforeTrailingComments = 1;
|
||||||
#if LLVM_VERSION_MAJOR >= 13
|
|
||||||
style.SpacesInAngles = FormatStyle::SIAS_Never;
|
style.SpacesInAngles = FormatStyle::SIAS_Never;
|
||||||
#else
|
|
||||||
style.SpacesInAngles = false;
|
|
||||||
#endif
|
|
||||||
style.SpacesInContainerLiterals = false;
|
style.SpacesInContainerLiterals = false;
|
||||||
#if LLVM_VERSION_MAJOR >= 17
|
#if LLVM_VERSION_MAJOR >= 17
|
||||||
style.SpacesInParens = FormatStyle::SIPO_Never;
|
style.SpacesInParens = FormatStyle::SIPO_Never;
|
||||||
@@ -225,9 +194,7 @@ void fromCppCodeStyleSettings(clang::format::FormatStyle &style,
|
|||||||
style.BreakBeforeBraces = FormatStyle::BS_Custom;
|
style.BreakBeforeBraces = FormatStyle::BS_Custom;
|
||||||
|
|
||||||
style.IndentCaseLabels = settings.indentSwitchLabels;
|
style.IndentCaseLabels = settings.indentSwitchLabels;
|
||||||
#if LLVM_VERSION_MAJOR >= 11
|
|
||||||
style.IndentCaseBlocks = settings.indentBlocksRelativeToSwitchLabels;
|
style.IndentCaseBlocks = settings.indentBlocksRelativeToSwitchLabels;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (settings.extraPaddingForConditionsIfConfusingAlign)
|
if (settings.extraPaddingForConditionsIfConfusingAlign)
|
||||||
style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
|
style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
|
||||||
|
|||||||
Reference in New Issue
Block a user