Clang: Add BuildDependencyCollector

IncludeCollector is renamed to BuildDependencyCollector. It is now
returning a BuildDependency instead of individual getter. The test coverage
is improved too.

Task-number: QTCREATORBUG-21379
Change-Id: Ifc2d1c40c85772cf498c21968de526f4408b6023
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-11-12 19:27:51 +01:00
parent e11ff791f0
commit 64a3a130ac
56 changed files with 1135 additions and 813 deletions

View File

@@ -135,6 +135,8 @@ clang::tooling::ClangTool ClangTool::createTool() const
tool.mapVirtualFile(toStringRef(unsavedFileContent.filePath),
toStringRef(unsavedFileContent.content));
tool.mapVirtualFile("/dummyFile", "#pragma once");
return tool;
}

View File

@@ -54,6 +54,12 @@ public:
&& first.lastModified == second.lastModified;
}
friend
bool operator<(const FileStatus &first, const FileStatus &second)
{
return first.filePathId < second.filePathId;
}
public:
FilePathId filePathId;
off_t size;

View File

@@ -34,17 +34,26 @@ namespace ClangBackEnd {
class SourceDependency
{
public:
SourceDependency(FilePathId filePathId,
FilePathId dependencyFilePathId)
: filePathId(filePathId),
dependencyFilePathId(dependencyFilePathId)
SourceDependency(FilePathId filePathId, FilePathId dependencyFilePathId)
: filePathId(filePathId)
, dependencyFilePathId(dependencyFilePathId)
{}
friend
bool operator==(SourceDependency first, SourceDependency second)
friend bool operator==(SourceDependency first, SourceDependency second)
{
return first.filePathId == second.filePathId
&& first.dependencyFilePathId == second.dependencyFilePathId;
&& first.dependencyFilePathId == second.dependencyFilePathId;
}
friend bool operator!=(SourceDependency first, SourceDependency second)
{
return !(first == second);
}
friend bool operator<(SourceDependency first, SourceDependency second)
{
return std::tie(first.filePathId, first.dependencyFilePathId)
< std::tie(second.filePathId, second.dependencyFilePathId);
}
public:
@@ -53,4 +62,4 @@ public:
};
using SourceDependencies = std::vector<SourceDependency>;
}
} // namespace ClangBackEnd

View File

@@ -145,7 +145,7 @@ public:
return SymbolIndex(reinterpret_cast<std::uintptr_t>(pointer));
}
void setSourceManager(const clang::SourceManager *sourceManager)
void setSourceManager(clang::SourceManager *sourceManager)
{
m_sourceManager = sourceManager;
}