forked from qt-creator/qt-creator
Clang: Handle native file in the file cache
Different types are introduced for normalized and native file path. So the compiler is warning you if you try the wrong format. Change-Id: I1da0686b142cbf9bb7578468c2b50f90a94cebf9 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
namespace llvm {
|
||||
template <typename T, unsigned N>
|
||||
class SmallVector;
|
||||
@@ -35,10 +37,7 @@ namespace ClangBackEnd {
|
||||
using USRName = llvm::SmallVector<char, 128>;
|
||||
|
||||
// use std::filesystem::path if it is supported by all compilers
|
||||
#ifdef _WIN32
|
||||
const char nativeSeperator = '\\';
|
||||
#else
|
||||
const char nativeSeperator = '/';
|
||||
#endif
|
||||
|
||||
static const char nativeSeparator = Utils::HostOsInfo::isWindowsHost() ? '\\' : '/';
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ struct FileContent
|
||||
const std::vector<std::string> &commandLine)
|
||||
: directory(directory),
|
||||
fileName(fileName),
|
||||
filePath(directory + nativeSeperator + fileName),
|
||||
filePath(directory + nativeSeparator + fileName),
|
||||
content(content),
|
||||
commandLine(commandLine)
|
||||
{}
|
||||
|
||||
@@ -40,11 +40,6 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
Utils::SmallStringView toStringView(clang::StringRef stringReference)
|
||||
{
|
||||
return Utils::SmallStringView(stringReference.data(), stringReference.size());
|
||||
}
|
||||
|
||||
class CollectSymbolsASTVisitor : public clang::RecursiveASTVisitor<CollectSymbolsASTVisitor>
|
||||
{
|
||||
public:
|
||||
@@ -111,7 +106,7 @@ public:
|
||||
|
||||
auto filePath = m_sourceManager.getFilename(sourceLocation);
|
||||
|
||||
FilePathId filePathId = m_filePathCache.filePathId(toStringView(filePath));
|
||||
FilePathId filePathId = m_filePathCache.filePathId(FilePath::fromNativeFilePath(filePath));
|
||||
|
||||
m_filePathIndices.emplace(clangFileId, filePathId);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace {
|
||||
|
||||
std::string concatFilePath(const clang::tooling::CompileCommand &compileCommand)
|
||||
{
|
||||
return compileCommand.Directory + nativeSeperator + compileCommand.Filename;
|
||||
return compileCommand.Directory + nativeSeparator + compileCommand.Filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ void appendSourceLocationsToSourceLocationsContainer(
|
||||
const auto fileId = decomposedLoction.first;
|
||||
const auto offset = decomposedLoction.second;
|
||||
const auto fileEntry = sourceManager.getFileEntryForID(fileId);
|
||||
auto filePath = fromNativePath(absolutePath(fileEntry->getName()));
|
||||
auto filePath = FilePath::fromNativeFilePath(absolutePath(fileEntry->getName()));
|
||||
|
||||
sourceLocationsContainer.insertSourceLocation(filePathCache.filePathId(filePath),
|
||||
fullSourceLocation.getSpellingLineNumber(),
|
||||
|
||||
@@ -139,7 +139,7 @@ FilePathId SourceRangeExtractor::findFileId(clang::FileID fileId, const clang::F
|
||||
}
|
||||
|
||||
auto filePath = absolutePath(fileEntry->getName());
|
||||
return filePathCache.filePathId(fromNativePath(filePath));
|
||||
return filePathCache.filePathId(FilePath::fromNativeFilePath(filePath));
|
||||
}
|
||||
|
||||
void SourceRangeExtractor::addSourceRange(const clang::SourceRange &sourceRange)
|
||||
|
||||
Reference in New Issue
Block a user