diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-02-06 17:18:15 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-02-11 15:23:26 +0000 |
commit | ffa043fb9983462ebeb143afb946c109e9369e7f (patch) | |
tree | 865c03ba0c37427b3d0acf45274b3b1659005f29 /src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h | |
parent | 7fe65851d99465d8bd9506ba53d8772381666111 (diff) | |
download | qt-creator-ffa043fb9983462ebeb143afb946c109e9369e7f.tar.gz |
Clang: Improve performance by reducing parsing
We generate one big file per project part so the preprocessor is skipping
the recurring includes.
This generated many errors about missing macros but we don't care
much about them during dependency collection step so we just
silence these errors with ignoring diagnostics consumer.
Change-Id: I5581d623b5d5f9995496252735577ea6b54790d9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h')
-rw-r--r-- | src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h b/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h index 8253092751..980d065fdb 100644 --- a/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h +++ b/src/tools/clangpchmanagerbackend/source/collectbuilddependencypreprocessorcallbacks.h @@ -72,15 +72,27 @@ public: void FileChanged(clang::SourceLocation sourceLocation, clang::PPCallbacks::FileChangeReason reason, clang::SrcMgr::CharacteristicKind, - clang::FileID) override + clang::FileID previousFileId) override { - if (reason == clang::PPCallbacks::EnterFile) - { - const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID( - m_sourceManager->getFileID(sourceLocation)); - if (fileEntry) { - addFileStatus(fileEntry); - addSourceFile(fileEntry); + if (reason == clang::PPCallbacks::EnterFile) { + clang::FileID currentFileId = m_sourceManager->getFileID(sourceLocation); + if (m_mainFileId.isInvalid()) { + m_mainFileId = currentFileId; + } else { + const clang::FileEntry *fileEntry = m_sourceManager->getFileEntryForID( + currentFileId); + if (fileEntry) { + if (previousFileId == m_mainFileId) { + uint sourceFileUID = fileEntry->getUID(); + auto notAlreadyIncluded = isNotAlreadyIncluded(sourceFileUID); + if (notAlreadyIncluded.first) + m_alreadyIncludedFileUIDs.insert(notAlreadyIncluded.second, + sourceFileUID); + } else { + addFileStatus(fileEntry); + addSourceFile(fileEntry); + } + } } } } @@ -96,7 +108,8 @@ public: const clang::Module * /*imported*/, clang::SrcMgr::CharacteristicKind fileType) override { - if (file) { + clang::FileID currentFileId = m_sourceManager->getFileID(hashLocation); + if (file && currentFileId != m_mainFileId) { addSourceDependency(file, hashLocation); auto fileUID = file->getUID(); auto sourceFileUID = m_sourceManager @@ -343,6 +356,7 @@ private: BuildDependency &m_buildDependency; const std::vector<uint> &m_excludedIncludeUID; std::vector<uint> &m_alreadyIncludedFileUIDs; + clang::FileID m_mainFileId; }; } // namespace ClangBackEnd |