Add system include path to HeaderPath and merge ProjectPartHeaderPath

System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Marco Bubke
2018-09-03 16:10:43 +02:00
parent 59e734d9da
commit 3abaf647d0
44 changed files with 237 additions and 320 deletions

View File

@@ -1740,7 +1740,7 @@ namespace {
QString findShortestInclude(const QString currentDocumentFilePath,
const QString candidateFilePath,
const ProjectPartHeaderPaths &headerPaths)
const ProjectExplorer::HeaderPaths &headerPaths)
{
QString result;
@@ -1749,7 +1749,7 @@ QString findShortestInclude(const QString currentDocumentFilePath,
if (fileInfo.path() == QFileInfo(currentDocumentFilePath).path()) {
result = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"');
} else {
foreach (const ProjectPartHeaderPath &headerPath, headerPaths) {
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
if (!candidateFilePath.startsWith(headerPath.path))
continue;
QString relativePath = candidateFilePath.mid(headerPath.path.size());
@@ -1764,12 +1764,12 @@ QString findShortestInclude(const QString currentDocumentFilePath,
}
QString findQtIncludeWithSameName(const QString &className,
const ProjectPartHeaderPaths &headerPaths)
const ProjectExplorer::HeaderPaths &headerPaths)
{
QString result;
// Check for a header file with the same name in the Qt include paths
foreach (const ProjectPartHeaderPath &headerPath, headerPaths) {
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
if (!headerPath.path.contains(QLatin1String("/Qt"))) // "QtCore", "QtGui" etc...
continue;
@@ -1784,9 +1784,9 @@ QString findQtIncludeWithSameName(const QString &className,
return result;
}
ProjectPartHeaderPaths relevantHeaderPaths(const QString &filePath)
ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
{
ProjectPartHeaderPaths headerPaths;
ProjectExplorer::HeaderPaths headerPaths;
CppModelManager *modelManager = CppModelManager::instance();
const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
@@ -1931,7 +1931,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QString className;
QList<Core::LocatorFilterEntry> matches;
const QString currentDocumentFilePath = interface.semanticInfo().doc->fileName();
const ProjectPartHeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
const ProjectExplorer::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
bool qtHeaderFileIncludeOffered = false;
// Find an include file through the locator