Clang: Add file cache

The database is using file path integer ids to handle file paths because
otherwise we would save many redundant data. This patch is improving it
further with the introduction of a database based file path cache. The
entries are now divided in a directory path and file name. This is quite
handy for directory based file watching.

Change-Id: I03f2e388e43f3d521d6bf8e39dfb95eb2309dc73
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-09-21 11:43:59 +02:00
committed by Tim Jenssen
parent 0be8240002
commit d2e15e5f1e
135 changed files with 3458 additions and 1517 deletions

View File

@@ -25,9 +25,10 @@
#pragma once
#include <stringcache.h>
#include <filepathcachingfwd.h>
#include <filepath.h>
#include <filepathid.h>
#include <utils/smallstringfwd.h>
@@ -59,7 +60,7 @@ class SourceRangeExtractor
public:
SourceRangeExtractor(const clang::SourceManager &sourceManager,
const clang::LangOptions &languageOptions,
ClangBackEnd::FilePathCache<std::mutex> &filePathCache,
FilePathCachingInterface &filePathCache,
SourceRangesContainer &sourceRangesContainer);
void addSourceRange(const clang::SourceRange &sourceRange);
@@ -74,21 +75,20 @@ public:
const clang::SourceRange extendSourceRangeToLastTokenEnd(const clang::SourceRange sourceRange);
private:
void insertSourceRange(uint fileId,
Utils::PathString &&filePath,
void insertSourceRange(FilePathId filePathId,
const clang::FullSourceLoc &startLocation,
uint startOffset,
const clang::FullSourceLoc &endLocation,
uint endOffset,
Utils::SmallString &&lineSnippet);
FilePathIndex findFileId(clang::FileID fileId, const clang::FileEntry *fileEntry) const;
FilePathId findFileId(clang::FileID fileId, const clang::FileEntry *fileEntry) const;
private:
mutable std::unordered_map<uint, uint> m_fileIdMapping;
mutable std::unordered_map<uint, FilePathId> m_fileIdMapping;
const clang::SourceManager &sourceManager;
const clang::LangOptions &languageOptions;
ClangBackEnd::FilePathCache<std::mutex> &filePathCache;
FilePathCachingInterface &filePathCache;
SourceRangesContainer &sourceRangesContainer;
};