Commit 3dd1d11f authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen

Clang: Fix path for clang query

Task-number: QTCREATORBUG-18814
Change-Id: I638fa4dd993e8efbabefc883622e1619b4e5d9cc
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent e9e3a7d5
...@@ -63,10 +63,10 @@ llvm::SmallString<256> absolutePath(clang::StringRef path) ...@@ -63,10 +63,10 @@ llvm::SmallString<256> absolutePath(clang::StringRef path)
return absolutePath; return absolutePath;
} }
template <typename Container> inline
Utils::PathString fromNativePath(Container container) Utils::PathString fromNativePath(const llvm::SmallString<256> &string)
{ {
Utils::PathString path(container.data(), container.size()); Utils::PathString path(string.data(), string.size());
#ifdef _WIN32 #ifdef _WIN32
std::replace(path.begin(), path.end(), '\\', '/'); std::replace(path.begin(), path.end(), '\\', '/');
...@@ -91,7 +91,7 @@ void appendSourceLocationsToSourceLocationsContainer( ...@@ -91,7 +91,7 @@ void appendSourceLocationsToSourceLocationsContainer(
const auto fileEntry = sourceManager.getFileEntryForID(fileId); const auto fileEntry = sourceManager.getFileEntryForID(fileId);
sourceLocationsContainer.insertFilePath(fileId.getHashValue(), sourceLocationsContainer.insertFilePath(fileId.getHashValue(),
fromNativePath(fileEntry->tryGetRealPathName())); fromNativePath(absolutePath(fileEntry->getName())));
sourceLocationsContainer.insertSourceLocation(fileId.getHashValue(), sourceLocationsContainer.insertSourceLocation(fileId.getHashValue(),
fullSourceLocation.getSpellingLineNumber(), fullSourceLocation.getSpellingLineNumber(),
fullSourceLocation.getSpellingColumnNumber(), fullSourceLocation.getSpellingColumnNumber(),
......
...@@ -69,6 +69,7 @@ std::reverse_iterator<Iterator> make_reverse_iterator(Iterator iterator) ...@@ -69,6 +69,7 @@ std::reverse_iterator<Iterator> make_reverse_iterator(Iterator iterator)
{ {
return std::reverse_iterator<Iterator>(iterator); return std::reverse_iterator<Iterator>(iterator);
} }
} }
const char *SourceRangeExtractor::findStartOfLineInBuffer(llvm::StringRef buffer, uint startOffset) const char *SourceRangeExtractor::findStartOfLineInBuffer(llvm::StringRef buffer, uint startOffset)
...@@ -152,7 +153,7 @@ uint SourceRangeExtractor::findFileId(clang::FileID fileId, const clang::FileEnt ...@@ -152,7 +153,7 @@ uint SourceRangeExtractor::findFileId(clang::FileID fileId, const clang::FileEnt
return found->second; return found->second;
} }
auto filePath = absolutePath(fileEntry->tryGetRealPathName()); auto filePath = absolutePath(fileEntry->getName());
return filePathCache.stringId(fromNativePath(filePath)); return filePathCache.stringId(fromNativePath(filePath));
} }
...@@ -175,7 +176,7 @@ void SourceRangeExtractor::addSourceRange(const clang::SourceRange &sourceRange) ...@@ -175,7 +176,7 @@ void SourceRangeExtractor::addSourceRange(const clang::SourceRange &sourceRange)
endOffset); endOffset);
insertSourceRange(findFileId(fileId, fileEntry), insertSourceRange(findFileId(fileId, fileEntry),
fromNativePath(fileEntry->tryGetRealPathName()), fromNativePath(absolutePath(fileEntry->getName())),
startSourceLocation, startSourceLocation,
startOffset, startOffset,
endSourceLocation, endSourceLocation,
......
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