diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-01-31 13:53:57 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-02-01 15:06:09 +0000 |
commit | 048224bef1e22fe2cdd4eb82853dfb900619f216 (patch) | |
tree | 3aef480243539421dfa2dfc84e56aa24af91c8a2 /src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h | |
parent | b2d3951bde80a611928b8d4ffe52a476ed25f5c6 (diff) | |
download | qt-creator-048224bef1e22fe2cdd4eb82853dfb900619f216.tar.gz |
Clang: Collect source dependencies
It is quite easy because we track the include directives in the
preprocessor callbacks.
Change-Id: I2d7bd67b31f50c0d8d4a46c57e83dffa0c558dc7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h b/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h index 9c5b701dfb..6dfc969fad 100644 --- a/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h +++ b/src/tools/clangrefactoringbackend/source/symbolsvisitorbase.h @@ -50,22 +50,30 @@ public: FilePathId filePathId(clang::SourceLocation sourceLocation) { - uint clangFileId = m_sourceManager.getFileID(sourceLocation).getHashValue(); + clang::FileID clangFileId = m_sourceManager.getFileID(sourceLocation); + const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(clangFileId); - auto found = m_filePathIndices.find(clangFileId); + return filePathId(fileEntry); + } + + FilePathId filePathId(const clang::FileEntry *fileEntry) + { + if (fileEntry) { + uint fileHash = fileEntry->getUID(); - if (found != m_filePathIndices.end()) - return found->second; + auto found = m_filePathIndices.find(fileHash); - auto filePath = m_sourceManager.getFilename(sourceLocation); + if (found != m_filePathIndices.end()) + return found->second; - if (filePath.size() > 0) { + auto filePath = fileEntry->getName(); FilePathId filePathId = m_filePathCache.filePathId(FilePath::fromNativeFilePath(absolutePath(filePath))); - m_filePathIndices.emplace(clangFileId, filePathId); + m_filePathIndices.emplace(fileHash, filePathId); return filePathId; } + return {}; } |