Merge remote-tracking branch 'origin/4.11'

Change-Id: I0657cee6b87eea7b3178548bebed85d5ac824519
This commit is contained in:
Eike Ziller
2020-01-03 08:57:33 +01:00
11 changed files with 67 additions and 16 deletions

View File

@@ -100,6 +100,12 @@ endif()
install(TARGETS OptionalSvg EXPORT QtCreator)
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)
if (APPLE)

View File

@@ -335,6 +335,11 @@ static void setHighDpiEnvironmentVariable()
&& !qEnvironmentVariableIsSet("QT_SCALE_FACTOR")
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
// work around QTBUG-80934
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::Round);
#endif
}
}

View File

@@ -441,6 +441,7 @@ public:
{
// Determine the driver mode from toolchain and flags.
m_builder.evaluateCompilerFlags();
m_isClMode = m_builder.isClStyle();
addLanguageOptions();
addGlobalDiagnosticOptions(); // Before addDiagnosticOptions() so users still can overwrite.
@@ -498,7 +499,10 @@ private:
? CppTools::UseBuildSystemWarnings::Yes
: 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()
@@ -537,6 +541,7 @@ private:
Core::Id m_diagnosticConfigId;
CppTools::UseBuildSystemWarnings m_useBuildSystemWarnings = CppTools::UseBuildSystemWarnings::No;
CppTools::CompilerOptionsBuilder m_builder;
bool m_isClMode = false;
QStringList m_options;
};
} // namespace

View File

@@ -48,11 +48,16 @@ using namespace CppTools;
namespace ClangTools {
namespace Internal {
static bool isClMode(const QStringList &options)
{
return options.contains("--driver-mode=cl");
}
static QStringList serializeDiagnosticsArguments(const QStringList &baseOptions,
const QString &outputFilePath)
{
const QStringList serializeArgs{"-serialize-diagnostics", outputFilePath};
if (baseOptions.contains("--driver-mode=cl"))
if (isClMode(baseOptions))
return clangArgsForCl(serializeArgs);
return serializeArgs;
}
@@ -102,7 +107,8 @@ static QStringList clangArguments(const ClangDiagnosticConfig &diagnosticConfig,
{
QStringList arguments;
arguments << ClangDiagnosticConfigsModel::globalDiagnosticOptions()
<< diagnosticConfig.clangOptions()
<< (isClMode(baseOptions) ? CppTools::clangArgsForCl(diagnosticConfig.clangOptions())
: diagnosticConfig.clangOptions())
<< baseOptions;
if (LOG().isDebugEnabled())

View File

@@ -467,7 +467,7 @@ void addCompileGroups(ProjectNode *targetRoot,
if (sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
buildFileNodes.emplace_back(std::move(node));
} else if (sourcePath.isChildOf(sourceDirectory)) {
sourceGroupNodes[si.sourceGroup]->addNode(std::move(node));
sourceGroupNodes[si.sourceGroup]->addNestedNode(std::move(node));
} else {
otherFileNodes.emplace_back(std::move(node));
}

View File

@@ -138,6 +138,7 @@ QStringList CompilerOptionsBuilder::build(ProjectFile::Kind fileKind,
addTargetTriple();
updateFileLanguage(fileKind);
addLanguageVersionAndExtensions();
enableExceptions();
addPrecompiledHeaderOptions(usePrecompiledHeaders);
addProjectConfigFileInclude();
@@ -272,6 +273,17 @@ void CompilerOptionsBuilder::addCompilerFlags()
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()
{
#ifndef UNIT_TESTS

View File

@@ -69,6 +69,7 @@ public:
void addExtraCodeModelFlags();
void addPicIfCompilerFlagsContainsIt();
void addCompilerFlags();
void enableExceptions();
void insertWrappedQtHeaders();
void addLanguageVersionAndExtensions();
void updateFileLanguage(ProjectFile::Kind fileKind);

View File

@@ -355,7 +355,6 @@ static void addBuiltinConfigs(ClangDiagnosticConfigsModel &model)
config.setClangOptions({
"-Wall",
"-Wextra",
"-Wno-c++98-compat"
});
model.appendOrUpdate(config);

View File

@@ -71,15 +71,10 @@ void HeaderPathFilter::removeGccInternalIncludePaths()
return;
const Utils::FilePath gccInstallDir = projectPart.toolChainInstallDir;
auto isGccInternalInclude = [gccInstallDir](const HeaderPath &headerPath){
const auto includePath = Utils::FilePath::fromString(headerPath.path);
if (includePath.isChildOf(gccInstallDir)) {
const QString remainingPath = headerPath.path.mid(gccInstallDir.toString().size());
// 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;
auto isGccInternalInclude = [gccInstallDir](const HeaderPath &headerPath) {
const auto filePath = Utils::FilePath::fromString(headerPath.path);
return filePath == gccInstallDir.pathAppended("include")
|| filePath == gccInstallDir.pathAppended("include-fixed");
};
Utils::erase(builtInHeaderPaths, isGccInternalInclude);

View File

@@ -444,6 +444,22 @@ TEST_F(CompilerOptionsBuilder, AddTargetTriple)
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)
{
CppTools::CompilerOptionsBuilder compilerOptionsBuilder{projectPart,
@@ -601,6 +617,8 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptions)
"-x",
"c++",
"-std=c++17",
"-fcxx-exceptions",
"-fexceptions",
"-DprojectFoo=projectBar",
"-I", IsPartOfHeader("wrappedQtHeaders"),
"-I", IsPartOfHeader(toNative("wrappedQtHeaders/QtCore").toStdString()),
@@ -632,6 +650,8 @@ TEST_F(CompilerOptionsBuilder, BuildAllOptionsCl)
"--target=x86_64-apple-darwin10",
"/TP",
"/std:c++17",
"-fcxx-exceptions",
"-fexceptions",
"-fms-compatibility-version=19.00",
"-DprojectFoo=projectBar",
"-D__FUNCSIG__=\"\"",

View File

@@ -245,7 +245,8 @@ TEST_F(HeaderPathFilter, ClangHeadersAndCppIncludesPathsOrderLinux)
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)
{
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)));
}
// 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.
TEST_F(HeaderPathFilter, RemoveGccInternalPathsExceptForStandardPaths)
{