Clang: Get file informations from symbols collector

We need the same information like file size and the last modification time
to check if a file has changed. This information will be saved to the
database.

Change-Id: Icf8eb9b6553945a563887e11aff9539c9b300b66
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-01-29 15:47:53 +01:00
parent 8aef667ad7
commit 70ab43ca62
12 changed files with 152 additions and 4 deletions

View File

@@ -25,6 +25,7 @@
#pragma once
#include "fileinformation.h"
#include "symbolsvisitorbase.h"
#include "sourcelocationsutils.h"
#include "sourcelocationentry.h"
@@ -48,6 +49,7 @@ public:
SourceLocationEntries &sourceLocationEntries,
FilePathIds &sourceFiles,
UsedMacros &usedMacros,
FileInformations &fileInformations,
FilePathCachingInterface &filePathCache,
const clang::SourceManager &sourceManager,
std::shared_ptr<clang::Preprocessor> &&preprocessor)
@@ -56,10 +58,28 @@ public:
m_symbolEntries(symbolEntries),
m_sourceLocationEntries(sourceLocationEntries),
m_sourceFiles(sourceFiles),
m_usedMacros(usedMacros)
m_usedMacros(usedMacros),
m_fileInformations(fileInformations)
{
}
void FileChanged(clang::SourceLocation sourceLocation,
clang::PPCallbacks::FileChangeReason reason,
clang::SrcMgr::CharacteristicKind,
clang::FileID)
{
if (reason == clang::PPCallbacks::EnterFile)
{
const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(
m_sourceManager.getFileID(sourceLocation));
if (fileEntry) {
m_fileInformations.emplace_back(filePathId(sourceLocation),
fileEntry->getSize(),
fileEntry->getModificationTime());
}
}
}
void InclusionDirective(clang::SourceLocation /*hashLocation*/,
const clang::Token &/*includeToken*/,
llvm::StringRef /*fileName*/,
@@ -264,6 +284,7 @@ private:
SourceLocationEntries &m_sourceLocationEntries;
FilePathIds &m_sourceFiles;
UsedMacros &m_usedMacros;
FileInformations &m_fileInformations;
bool m_skipInclude = false;
};