Commit 5ad44318 authored by Marco Bubke's avatar Marco Bubke

Clang: Improve caching of file path ids

Clang is internally using an id to handle files. We add now a mapping from
their AST local id to out global id.

Change-Id: I2d724761287b5e915237175134ec5d3b92099ddb
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent efcfb5ee
......@@ -94,9 +94,20 @@ public:
FilePathIndex filePathId(clang::SourceLocation sourceLocation)
{
auto filePath = m_sourceManager.getFilename(sourceLocation);
uint clangFileId = m_sourceManager.getFileID(sourceLocation).getHashValue();
return m_filePathCache.stringId(toStringView(filePath));
auto found = m_filePathIndices.find(clangFileId);
if (found != m_filePathIndices.end())
return found->second;
auto filePath = m_sourceManager.getFilename(sourceLocation);
FilePathIndex index = m_filePathCache.stringId(toStringView(filePath));
m_filePathIndices.emplace(clangFileId, index);
return index;
}
LineColumn lineColum(clang::SourceLocation sourceLocation)
......@@ -121,6 +132,7 @@ public:
private:
SymbolEntries &m_symbolEntries;
std::unordered_map<uint, FilePathIndex> m_filePathIndices;
SourceLocationEntries &m_sourceLocationEntries;
FilePathCache<> &m_filePathCache;
const clang::SourceManager &m_sourceManager;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment