forked from qt-creator/qt-creator
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:
@@ -351,7 +351,16 @@ static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &proj
|
||||
}
|
||||
}
|
||||
|
||||
Utils::sort(fileInfos, &FileInfo::file);
|
||||
Utils::sort(fileInfos, [](const FileInfo &fi1, const FileInfo &fi2) {
|
||||
if (fi1.file == fi2.file) {
|
||||
// If the same file appears more than once, prefer contexts where the file is
|
||||
// built as part of an application or library to those where it may not be,
|
||||
// e.g. because it is just listed as some sort of resource.
|
||||
return fi1.projectPart->buildTargetType != BuildTargetType::Unknown
|
||||
&& fi2.projectPart->buildTargetType == BuildTargetType::Unknown;
|
||||
}
|
||||
return fi1.file < fi2.file;
|
||||
});
|
||||
fileInfos.erase(std::unique(fileInfos.begin(), fileInfos.end()), fileInfos.end());
|
||||
|
||||
return fileInfos;
|
||||
|
Reference in New Issue
Block a user