forked from qt-creator/qt-creator
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:
@@ -25,28 +25,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <filepathcachinginterface.h>
|
||||
#include <sourcelocationscontainer.h>
|
||||
#include <sourcerangescontainer.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning( disable : 4100 )
|
||||
#endif
|
||||
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
#include <clang/Lex/Lexer.h>
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
#include <llvm/Support/FileUtilities.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <iterator>
|
||||
#include <cctype>
|
||||
|
||||
@@ -79,7 +66,8 @@ inline
|
||||
void appendSourceLocationsToSourceLocationsContainer(
|
||||
ClangBackEnd::SourceLocationsContainer &sourceLocationsContainer,
|
||||
const std::vector<clang::SourceLocation> &sourceLocations,
|
||||
const clang::SourceManager &sourceManager)
|
||||
const clang::SourceManager &sourceManager,
|
||||
FilePathCachingInterface &filePathCache)
|
||||
{
|
||||
sourceLocationsContainer.reserve(sourceLocations.size());
|
||||
|
||||
@@ -89,10 +77,9 @@ void appendSourceLocationsToSourceLocationsContainer(
|
||||
const auto fileId = decomposedLoction.first;
|
||||
const auto offset = decomposedLoction.second;
|
||||
const auto fileEntry = sourceManager.getFileEntryForID(fileId);
|
||||
auto filePath = fromNativePath(absolutePath(fileEntry->getName()));
|
||||
|
||||
sourceLocationsContainer.insertFilePath(fileId.getHashValue(),
|
||||
fromNativePath(absolutePath(fileEntry->getName())));
|
||||
sourceLocationsContainer.insertSourceLocation(fileId.getHashValue(),
|
||||
sourceLocationsContainer.insertSourceLocation(filePathCache.filePathId(filePath),
|
||||
fullSourceLocation.getSpellingLineNumber(),
|
||||
fullSourceLocation.getSpellingColumnNumber(),
|
||||
offset);
|
||||
|
||||
Reference in New Issue
Block a user