forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.11'
Change-Id: I0657cee6b87eea7b3178548bebed85d5ac824519
This commit is contained in:
@@ -100,6 +100,12 @@ endif()
|
|||||||
install(TARGETS OptionalSvg EXPORT QtCreator)
|
install(TARGETS OptionalSvg EXPORT QtCreator)
|
||||||
|
|
||||||
find_package(Clang COMPONENTS libclang QUIET)
|
find_package(Clang COMPONENTS libclang QUIET)
|
||||||
|
# silence a lot of warnings from building against llvm
|
||||||
|
# this would better fit inside a central libclang detection/include cmake file, but since we do not
|
||||||
|
# have one put it temporary here
|
||||||
|
if(MSVC AND TARGET libclang)
|
||||||
|
target_compile_options(libclang INTERFACE /wd4100 /wd4141 /wd4146 /wd4244 /wd4267 /wd4291)
|
||||||
|
endif()
|
||||||
find_package(LLVM QUIET)
|
find_package(LLVM QUIET)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@@ -335,6 +335,11 @@ static void setHighDpiEnvironmentVariable()
|
|||||||
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
|
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
|
||||||
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
|
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
// work around QTBUG-80934
|
||||||
|
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
|
||||||
|
Qt::HighDpiScaleFactorRoundingPolicy::Round);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -441,6 +441,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Determine the driver mode from toolchain and flags.
|
// Determine the driver mode from toolchain and flags.
|
||||||
m_builder.evaluateCompilerFlags();
|
m_builder.evaluateCompilerFlags();
|
||||||
|
m_isClMode = m_builder.isClStyle();
|
||||||
|
|
||||||
addLanguageOptions();
|
addLanguageOptions();
|
||||||
addGlobalDiagnosticOptions(); // Before addDiagnosticOptions() so users still can overwrite.
|
addGlobalDiagnosticOptions(); // Before addDiagnosticOptions() so users still can overwrite.
|
||||||
@@ -498,7 +499,10 @@ private:
|
|||||||
? CppTools::UseBuildSystemWarnings::Yes
|
? CppTools::UseBuildSystemWarnings::Yes
|
||||||
: CppTools::UseBuildSystemWarnings::No;
|
: CppTools::UseBuildSystemWarnings::No;
|
||||||
|
|
||||||
m_options.append(diagnosticConfig.clangOptions());
|
const QStringList options = m_isClMode
|
||||||
|
? CppTools::clangArgsForCl(diagnosticConfig.clangOptions())
|
||||||
|
: diagnosticConfig.clangOptions();
|
||||||
|
m_options.append(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addGlobalDiagnosticOptions()
|
void addGlobalDiagnosticOptions()
|
||||||
@@ -537,6 +541,7 @@ private:
|
|||||||
Core::Id m_diagnosticConfigId;
|
Core::Id m_diagnosticConfigId;
|
||||||
CppTools::UseBuildSystemWarnings m_useBuildSystemWarnings = CppTools::UseBuildSystemWarnings::No;
|
CppTools::UseBuildSystemWarnings m_useBuildSystemWarnings = CppTools::UseBuildSystemWarnings::No;
|
||||||
CppTools::CompilerOptionsBuilder m_builder;
|
CppTools::CompilerOptionsBuilder m_builder;
|
||||||
|
bool m_isClMode = false;
|
||||||
QStringList m_options;
|
QStringList m_options;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -48,11 +48,16 @@ using namespace CppTools;
|
|||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
static bool isClMode(const QStringList &options)
|
||||||
|
{
|
||||||
|
return options.contains("--driver-mode=cl");
|
||||||
|
}
|
||||||
|
|
||||||
static QStringList serializeDiagnosticsArguments(const QStringList &baseOptions,
|
static QStringList serializeDiagnosticsArguments(const QStringList &baseOptions,
|
||||||
const QString &outputFilePath)
|
const QString &outputFilePath)
|
||||||
{
|
{
|
||||||
const QStringList serializeArgs{"-serialize-diagnostics", outputFilePath};
|
const QStringList serializeArgs{"-serialize-diagnostics", outputFilePath};
|
||||||
if (baseOptions.contains("--driver-mode=cl"))
|
if (isClMode(baseOptions))
|
||||||
return clangArgsForCl(serializeArgs);
|
return clangArgsForCl(serializeArgs);
|
||||||
return serializeArgs;
|
return serializeArgs;
|
||||||
}
|
}
|
||||||
@@ -102,7 +107,8 @@ static QStringList clangArguments(const ClangDiagnosticConfig &diagnosticConfig,
|
|||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << ClangDiagnosticConfigsModel::globalDiagnosticOptions()
|
arguments << ClangDiagnosticConfigsModel::globalDiagnosticOptions()
|
||||||
<< diagnosticConfig.clangOptions()
|
<< (isClMode(baseOptions) ? CppTools::clangArgsForCl(diagnosticConfig.clangOptions())
|
||||||
|
: diagnosticConfig.clangOptions())
|
||||||
<< baseOptions;
|
<< baseOptions;
|
||||||
|
|
||||||
if (LOG().isDebugEnabled())
|
if (LOG().isDebugEnabled())
|
||||||
|
@@ -467,7 +467,7 @@ void addCompileGroups(ProjectNode *targetRoot,
|
|||||||
if (sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
|
if (sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
|
||||||
buildFileNodes.emplace_back(std::move(node));
|
buildFileNodes.emplace_back(std::move(node));
|
||||||
} else if (sourcePath.isChildOf(sourceDirectory)) {
|
} else if (sourcePath.isChildOf(sourceDirectory)) {
|
||||||
sourceGroupNodes[si.sourceGroup]->addNode(std::move(node));
|
sourceGroupNodes[si.sourceGroup]->addNestedNode(std::move(node));
|
||||||
} else {
|
} else {
|
||||||
otherFileNodes.emplace_back(std::move(node));
|
otherFileNodes.emplace_back(std::move(node));
|
||||||
}
|
}
|
||||||
|
@@ -138,6 +138,7 @@ QStringList CompilerOptionsBuilder::build(ProjectFile::Kind fileKind,
|
|||||||
addTargetTriple();
|
addTargetTriple();
|
||||||
updateFileLanguage(fileKind);
|
updateFileLanguage(fileKind);
|
||||||
addLanguageVersionAndExtensions();
|
addLanguageVersionAndExtensions();
|
||||||
|
enableExceptions();
|
||||||
|
|
||||||
addPrecompiledHeaderOptions(usePrecompiledHeaders);
|
addPrecompiledHeaderOptions(usePrecompiledHeaders);
|
||||||
addProjectConfigFileInclude();
|
addProjectConfigFileInclude();
|
||||||
@@ -272,6 +273,17 @@ void CompilerOptionsBuilder::addCompilerFlags()
|
|||||||
add(m_compilerFlags.flags);
|
add(m_compilerFlags.flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompilerOptionsBuilder::enableExceptions()
|
||||||
|
{
|
||||||
|
// With "--driver-mode=cl" exceptions are disabled (clang 8).
|
||||||
|
// This is most likely due to incomplete exception support of clang.
|
||||||
|
// However, as we need exception support only in the frontend,
|
||||||
|
// enabling them explicitly should be fine.
|
||||||
|
if (m_projectPart.languageVersion > ::Utils::LanguageVersion::LatestC)
|
||||||
|
add("-fcxx-exceptions");
|
||||||
|
add("-fexceptions");
|
||||||
|
}
|
||||||
|
|
||||||
static QString creatorResourcePath()
|
static QString creatorResourcePath()
|
||||||
{
|
{
|
||||||
#ifndef UNIT_TESTS
|
#ifndef UNIT_TESTS
|
||||||
|
@@ -69,6 +69,7 @@ public:
|
|||||||
void addExtraCodeModelFlags();
|
void addExtraCodeModelFlags();
|
||||||
void addPicIfCompilerFlagsContainsIt();
|
void addPicIfCompilerFlagsContainsIt();
|
||||||
void addCompilerFlags();
|
void addCompilerFlags();
|
||||||
|
void enableExceptions();
|
||||||
void insertWrappedQtHeaders();
|
void insertWrappedQtHeaders();
|
||||||
void addLanguageVersionAndExtensions();
|
void addLanguageVersionAndExtensions();
|
||||||
void updateFileLanguage(ProjectFile::Kind fileKind);
|
void updateFileLanguage(ProjectFile::Kind fileKind);
|
||||||
|
@@ -355,7 +355,6 @@ static void addBuiltinConfigs(ClangDiagnosticConfigsModel &model)
|
|||||||
config.setClangOptions({
|
config.setClangOptions({
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-Wextra",
|
"-Wextra",
|
||||||
"-Wno-c++98-compat"
|
|
||||||
});
|
});
|
||||||
model.appendOrUpdate(config);
|
model.appendOrUpdate(config);
|
||||||
|
|
||||||
|
@@ -72,14 +72,9 @@ void HeaderPathFilter::removeGccInternalIncludePaths()
|
|||||||
|
|
||||||
const Utils::FilePath gccInstallDir = projectPart.toolChainInstallDir;
|
const Utils::FilePath gccInstallDir = projectPart.toolChainInstallDir;
|
||||||
auto isGccInternalInclude = [gccInstallDir](const HeaderPath &headerPath) {
|
auto isGccInternalInclude = [gccInstallDir](const HeaderPath &headerPath) {
|
||||||
const auto includePath = Utils::FilePath::fromString(headerPath.path);
|
const auto filePath = Utils::FilePath::fromString(headerPath.path);
|
||||||
if (includePath.isChildOf(gccInstallDir)) {
|
return filePath == gccInstallDir.pathAppended("include")
|
||||||
const QString remainingPath = headerPath.path.mid(gccInstallDir.toString().size());
|
|| filePath == gccInstallDir.pathAppended("include-fixed");
|
||||||
// MinGW ships the standard library headers in "<installdir>/include/c++".
|
|
||||||
// Ensure that we do not remove include paths pointing there.
|
|
||||||
return !remainingPath.startsWith("/include/c++");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Utils::erase(builtInHeaderPaths, isGccInternalInclude);
|
Utils::erase(builtInHeaderPaths, isGccInternalInclude);
|
||||||
|
@@ -444,6 +444,22 @@ TEST_F(CompilerOptionsBuilder, AddTargetTriple)
|
|||||||
ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("--target=x86_64-apple-darwin10"));
|
ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("--target=x86_64-apple-darwin10"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CompilerOptionsBuilder, EnableCExceptions)
|
||||||
|
{
|
||||||
|
projectPart.languageVersion = Utils::LanguageVersion::C99;
|
||||||
|
|
||||||
|
compilerOptionsBuilder.enableExceptions();
|
||||||
|
|
||||||
|
ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-fexceptions"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CompilerOptionsBuilder, EnableCXXExceptions)
|
||||||
|
{
|
||||||
|
compilerOptionsBuilder.enableExceptions();
|
||||||
|
|
||||||
|
ASSERT_THAT(compilerOptionsBuilder.options(), ElementsAre("-fcxx-exceptions", "-fexceptions"));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(CompilerOptionsBuilder, InsertWrappedQtHeaders)
|
TEST_F(CompilerOptionsBuilder, InsertWrappedQtHeaders)
|
||||||
{
|
{
|
||||||
CppTools::CompilerOptionsBuilder compilerOptionsBuilder{projectPart,
|
CppTools::CompilerOptionsBuilder compilerOptionsBuilder{projectPart,
|
||||||
@@ -601,6 +617,8 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptions)
|
|||||||
"-x",
|
"-x",
|
||||||
"c++",
|
"c++",
|
||||||
"-std=c++17",
|
"-std=c++17",
|
||||||
|
"-fcxx-exceptions",
|
||||||
|
"-fexceptions",
|
||||||
"-DprojectFoo=projectBar",
|
"-DprojectFoo=projectBar",
|
||||||
"-I", IsPartOfHeader("wrappedQtHeaders"),
|
"-I", IsPartOfHeader("wrappedQtHeaders"),
|
||||||
"-I", IsPartOfHeader(toNative("wrappedQtHeaders/QtCore").toStdString()),
|
"-I", IsPartOfHeader(toNative("wrappedQtHeaders/QtCore").toStdString()),
|
||||||
@@ -632,6 +650,8 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptionsCl)
|
|||||||
"--target=x86_64-apple-darwin10",
|
"--target=x86_64-apple-darwin10",
|
||||||
"/TP",
|
"/TP",
|
||||||
"/std:c++17",
|
"/std:c++17",
|
||||||
|
"-fcxx-exceptions",
|
||||||
|
"-fexceptions",
|
||||||
"-fms-compatibility-version=19.00",
|
"-fms-compatibility-version=19.00",
|
||||||
"-DprojectFoo=projectBar",
|
"-DprojectFoo=projectBar",
|
||||||
"-D__FUNCSIG__=\"\"",
|
"-D__FUNCSIG__=\"\"",
|
||||||
|
@@ -245,7 +245,8 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux)
|
|||||||
HasBuiltIn("/builtin_path")));
|
HasBuiltIn("/builtin_path")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include paths below the installation dir should be removed as they confuse clang.
|
// GCC-internal include paths like <installdir>/include and <installdir/include-next> might confuse
|
||||||
|
// clang and should be filtered out. clang on the command line filters them out, too.
|
||||||
TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
|
TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
|
||||||
{
|
{
|
||||||
projectPart.toolChainInstallDir = Utils::FilePath::fromUtf8("/usr/lib/gcc/x86_64-linux-gnu/7");
|
projectPart.toolChainInstallDir = Utils::FilePath::fromUtf8("/usr/lib/gcc/x86_64-linux-gnu/7");
|
||||||
@@ -264,7 +265,8 @@ TEST_F(HeaderPathFilter, RemoveGccInternalPaths)
|
|||||||
ASSERT_THAT(filter.builtInHeaderPaths, ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR)));
|
ASSERT_THAT(filter.builtInHeaderPaths, ElementsAre(HasBuiltIn(CLANG_RESOURCE_DIR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// MinGW ships the standard library headers in "<installdir>/include/c++".
|
// Some distributions ship the standard library headers in "<installdir>/include/c++" (MinGW)
|
||||||
|
// or e.g. "<installdir>/include/g++-v8" (Gentoo).
|
||||||
// Ensure that we do not remove include paths pointing there.
|
// Ensure that we do not remove include paths pointing there.
|
||||||
TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths)
|
TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user