clang-tidy: Consider context when encountering duplicate files

Prefer source files from contexts where we know that they actually get
built and thus should have includes and compiler flags properly set up.
Also fix the qmake and qbs project managers to not mislabel any non-
application products as libraries.

Fixes: QTCREATORBUG-23394
Change-Id: I0d122c7b58e12d14d68a1ca7337df83074299cd7
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
This commit is contained in:
Christian Kandeler
2020-06-03 10:32:42 +02:00
parent e115e9b970
commit 1d2af6b4cc
3 changed files with 33 additions and 8 deletions

View File

@@ -290,10 +290,18 @@ void QmakeBuildSystem::updateCppCodeModel()
rpp.setDisplayName(pro->displayName());
rpp.setProjectFileLocation(pro->filePath().toString());
rpp.setBuildSystemTarget(pro->filePath().toString());
const bool isExecutable = pro->projectType() == ProjectType::ApplicationTemplate;
rpp.setBuildTargetType(isExecutable ? ProjectExplorer::BuildTargetType::Executable
: ProjectExplorer::BuildTargetType::Library);
switch (pro->projectType()) {
case ProjectType::ApplicationTemplate:
rpp.setBuildTargetType(BuildTargetType::Executable);
break;
case ProjectType::SharedLibraryTemplate:
case ProjectType::StaticLibraryTemplate:
rpp.setBuildTargetType(BuildTargetType::Library);
break;
default:
rpp.setBuildTargetType(BuildTargetType::Unknown);
break;
}
rpp.setFlagsForCxx({kitInfo.cxxToolChain, pro->variableValue(Variable::CppFlags)});
rpp.setFlagsForC({kitInfo.cToolChain, pro->variableValue(Variable::CFlags)});
rpp.setMacros(ProjectExplorer::Macro::toMacros(pro->cxxDefines()));