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