forked from qt-creator/qt-creator
Clang: Don't index already indexed symbols
We don't index system headers any more and introduce a first step to decrease double indexing. For that we introduces the SourcesManager which so far tells you only if a file was already indexed for a certain time stamp. Change-Id: Icde54465693ca84a622764c595635cac365c0111 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "sourcelocationsutils.h"
|
||||
#include "sourcesmanager.h"
|
||||
#include "symbolentry.h"
|
||||
|
||||
#include <filepathcachinginterface.h>
|
||||
|
||||
@@ -43,9 +45,11 @@ class SymbolsVisitorBase
|
||||
{
|
||||
public:
|
||||
SymbolsVisitorBase(FilePathCachingInterface &filePathCache,
|
||||
const clang::SourceManager *sourceManager)
|
||||
const clang::SourceManager *sourceManager,
|
||||
SourcesManager &sourcesManager)
|
||||
: m_filePathCache(filePathCache),
|
||||
m_sourceManager(sourceManager)
|
||||
m_sourceManager(sourceManager),
|
||||
m_sourcesManager(sourcesManager)
|
||||
{}
|
||||
|
||||
FilePathId filePathId(clang::SourceLocation sourceLocation)
|
||||
@@ -56,6 +60,19 @@ public:
|
||||
return filePathId(fileEntry);
|
||||
}
|
||||
|
||||
bool alreadyParsed(clang::FileID fileId)
|
||||
{
|
||||
const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID(fileId);
|
||||
|
||||
return m_sourcesManager.alreadyParsed(filePathId(fileEntry),
|
||||
fileEntry->getModificationTime());
|
||||
}
|
||||
|
||||
bool alreadyParsed(clang::SourceLocation sourceLocation)
|
||||
{
|
||||
return alreadyParsed(m_sourceManager->getFileID(sourceLocation));
|
||||
}
|
||||
|
||||
FilePathId filePathId(const clang::FileEntry *fileEntry)
|
||||
{
|
||||
if (fileEntry) {
|
||||
@@ -128,10 +145,17 @@ public:
|
||||
m_sourceManager = sourceManager;
|
||||
}
|
||||
|
||||
bool isInSystemHeader(clang::FileID fileId) const
|
||||
{
|
||||
return clang::SrcMgr::isSystem(
|
||||
m_sourceManager->getSLocEntry(fileId).getFile().getFileCharacteristic());
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<FilePathId> m_filePathIndices;
|
||||
FilePathCachingInterface &m_filePathCache;
|
||||
const clang::SourceManager *m_sourceManager = nullptr;
|
||||
SourcesManager &m_sourcesManager;
|
||||
};
|
||||
|
||||
} // namespace ClangBackend
|
||||
|
||||
Reference in New Issue
Block a user