forked from qt-creator/qt-creator
Clang: Use full paths in compilation database for symbol collector
We we FilePath and NativeFilePath so that compiler warns us if we mix them up. Change-Id: I33d7abc7e4e724dff2a9b2b9b23deea8b358ccfd Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <clangrefactoringbackend_global.h>
|
||||
|
||||
#include <filecontainerv2.h>
|
||||
#include <nativefilepath.h>
|
||||
#include <sourcelocationscontainer.h>
|
||||
|
||||
#include <clang/Tooling/Refactoring.h>
|
||||
@@ -43,50 +44,34 @@ namespace ClangBackEnd {
|
||||
|
||||
struct FileContent
|
||||
{
|
||||
FileContent(const std::string &directory,
|
||||
const std::string &fileName,
|
||||
const std::string &content,
|
||||
const std::vector<std::string> &commandLine)
|
||||
: directory(directory),
|
||||
fileName(fileName),
|
||||
filePath(directory + nativeSeparator + fileName),
|
||||
content(content),
|
||||
commandLine(commandLine)
|
||||
FileContent(NativeFilePath &&filePath, const Utils::SmallString &content)
|
||||
: filePath(std::move(filePath))
|
||||
, content(std::move(content))
|
||||
{}
|
||||
|
||||
std::string directory;
|
||||
std::string fileName;
|
||||
std::string filePath;
|
||||
NativeFilePath filePath;
|
||||
std::string content;
|
||||
std::vector<std::string> commandLine;
|
||||
};
|
||||
|
||||
struct UnsavedFileContent
|
||||
{
|
||||
UnsavedFileContent(Utils::PathString &&filePath,
|
||||
Utils::SmallString &&content)
|
||||
: filePath(std::move(filePath)),
|
||||
content(std::move(content))
|
||||
UnsavedFileContent(NativeFilePath &&filePath, Utils::SmallString &&content)
|
||||
: filePath(std::move(filePath))
|
||||
, content(std::move(content))
|
||||
{}
|
||||
|
||||
Utils::PathString filePath;
|
||||
NativeFilePath filePath;
|
||||
Utils::SmallString content;
|
||||
};
|
||||
|
||||
class ClangTool
|
||||
{
|
||||
public:
|
||||
void addFile(std::string &&directory,
|
||||
std::string &&fileName,
|
||||
std::string &&content,
|
||||
std::vector<std::string> &&commandLine);
|
||||
|
||||
template <typename Container>
|
||||
void addFiles(const Container &filePaths,
|
||||
const Utils::SmallStringVector &arguments);
|
||||
void addFiles(const FilePaths &filePaths,
|
||||
const Utils::SmallStringVector &arguments);
|
||||
void addFile(FilePath &&filePath,
|
||||
Utils::SmallString &&content,
|
||||
Utils::SmallStringVector &&commandLine);
|
||||
|
||||
void addFiles(const FilePaths &filePaths, const Utils::SmallStringVector &arguments);
|
||||
|
||||
void addUnsavedFiles(const V2::FileContainers &unsavedFiles);
|
||||
|
||||
@@ -102,11 +87,4 @@ private:
|
||||
std::vector<UnsavedFileContent> m_unsavedFileContents;
|
||||
};
|
||||
|
||||
extern template
|
||||
void ClangTool::addFiles<Utils::SmallStringVector>(const Utils::SmallStringVector &filePaths,
|
||||
const Utils::SmallStringVector &arguments);
|
||||
extern template
|
||||
void ClangTool::addFiles<Utils::PathStringVector>(const Utils::PathStringVector &filePaths,
|
||||
const Utils::SmallStringVector &arguments);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Reference in New Issue
Block a user