From dae4477cd367d115e2011cfedae6b1d5dbc22cb7 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Mon, 3 Jul 2017 11:12:00 +0200 Subject: Clang: Make file ids unique Clang file ids are only unique for one query. Because we query in parallel we have to manage our own unique ids. Change-Id: I67d57d8b1766cab75ad252a14e57bbf9dc5fdb79 Reviewed-by: Tim Jenssen --- .../clangrefactoringbackend/source/sourcelocationsutils.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/tools/clangrefactoringbackend/source/sourcelocationsutils.h') diff --git a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h index 78076f5f2b..df07b42daa 100644 --- a/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h +++ b/src/tools/clangrefactoringbackend/source/sourcelocationsutils.h @@ -53,7 +53,7 @@ namespace ClangBackEnd { inline -llvm::SmallString<256> absolutePath(const llvm::StringRef &path) +llvm::SmallString<256> absolutePath(clang::StringRef path) { llvm::SmallString<256> absolutePath(path); @@ -64,9 +64,9 @@ llvm::SmallString<256> absolutePath(const llvm::StringRef &path) } template -Utils::SmallString fromNativePath(Container container) +Utils::PathString fromNativePath(Container container) { - Utils::SmallString path(container.data(), container.size()); + Utils::PathString path(container.data(), container.size()); #ifdef _WIN32 std::replace(path.begin(), path.end(), '\\', '/'); @@ -89,13 +89,9 @@ void appendSourceLocationsToSourceLocationsContainer( const auto fileId = decomposedLoction.first; const auto offset = decomposedLoction.second; const auto fileEntry = sourceManager.getFileEntryForID(fileId); - auto filePath = absolutePath(fileEntry->getName()); - const auto fileName = llvm::sys::path::filename(filePath); - llvm::sys::path::remove_filename(filePath); sourceLocationsContainer.insertFilePath(fileId.getHashValue(), - fromNativePath(filePath), - fromNativePath(fileName)); + fromNativePath(fileEntry->tryGetRealPathName())); sourceLocationsContainer.insertSourceLocation(fileId.getHashValue(), fullSourceLocation.getSpellingLineNumber(), fullSourceLocation.getSpellingColumnNumber(), -- cgit v1.2.1