forked from qt-creator/qt-creator
PchManager: Fix generated file handling in PchCreator
Task-number: QTCREATORBUG-21843 Change-Id: I0517b87725117b7db7db14d32b737a0a6f2b3c35 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -148,7 +148,7 @@ const ProjectPartPch &PchCreator::projectPartPch()
|
|||||||
|
|
||||||
void PchCreator::setUnsavedFiles(const V2::FileContainers &fileContainers)
|
void PchCreator::setUnsavedFiles(const V2::FileContainers &fileContainers)
|
||||||
{
|
{
|
||||||
m_unsavedFiles = fileContainers;
|
m_clangTool.addUnsavedFiles(fileContainers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PchCreator::setIsUsed(bool isUsed)
|
void PchCreator::setIsUsed(bool isUsed)
|
||||||
@@ -163,6 +163,7 @@ bool PchCreator::isUsed() const
|
|||||||
|
|
||||||
void PchCreator::clear()
|
void PchCreator::clear()
|
||||||
{
|
{
|
||||||
|
m_clangTool = ClangTool{};
|
||||||
m_projectPartPch = {};
|
m_projectPartPch = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,12 +89,16 @@ public:
|
|||||||
static std::unique_ptr<QFile> generateFileWithContent(const Utils::SmallString &filePath,
|
static std::unique_ptr<QFile> generateFileWithContent(const Utils::SmallString &filePath,
|
||||||
const Utils::SmallString &content);
|
const Utils::SmallString &content);
|
||||||
|
|
||||||
|
const ClangTool &clangTool() const
|
||||||
|
{
|
||||||
|
return m_clangTool;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std::mt19937_64 randomNumberGenator{std::random_device{}()};
|
mutable std::mt19937_64 randomNumberGenator{std::random_device{}()};
|
||||||
ClangTool m_clangTool;
|
ClangTool m_clangTool;
|
||||||
ProjectPartPch m_projectPartPch;
|
ProjectPartPch m_projectPartPch;
|
||||||
FilePathCaching m_filePathCache;
|
FilePathCaching m_filePathCache;
|
||||||
V2::FileContainers m_unsavedFiles;
|
|
||||||
Environment &m_environment;
|
Environment &m_environment;
|
||||||
PchManagerClientInterface &m_pchManagerClient;
|
PchManagerClientInterface &m_pchManagerClient;
|
||||||
bool m_isUsed = false;
|
bool m_isUsed = false;
|
||||||
|
@@ -149,4 +149,10 @@ clang::tooling::ClangTool ClangTool::createOutputTool() const
|
|||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClangTool::isClean() const
|
||||||
|
{
|
||||||
|
return m_sourceFilePaths.empty() && m_fileContents.empty()
|
||||||
|
&& m_compilationDatabase.getAllFiles().empty() && m_unsavedFileContents.empty();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
||||||
|
@@ -93,6 +93,10 @@ public:
|
|||||||
clang::tooling::ClangTool createTool() const;
|
clang::tooling::ClangTool createTool() const;
|
||||||
clang::tooling::ClangTool createOutputTool() const;
|
clang::tooling::ClangTool createOutputTool() const;
|
||||||
|
|
||||||
|
bool isClean() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefactoringCompilationDatabase m_compilationDatabase;
|
RefactoringCompilationDatabase m_compilationDatabase;
|
||||||
std::vector<FileContent> m_fileContents;
|
std::vector<FileContent> m_fileContents;
|
||||||
|
@@ -227,6 +227,15 @@ TEST_F(PchCreatorVerySlowTest, ProjectPartPchCleared)
|
|||||||
ASSERT_THAT(creator.projectPartPch(), ClangBackEnd::ProjectPartPch{});
|
ASSERT_THAT(creator.projectPartPch(), ClangBackEnd::ProjectPartPch{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PchCreatorVerySlowTest, ClangToolCleared)
|
||||||
|
{
|
||||||
|
creator.generatePch(std::move(pchTask1));
|
||||||
|
|
||||||
|
creator.clear();
|
||||||
|
|
||||||
|
ASSERT_TRUE(creator.clangTool().isClean());
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(PchCreatorVerySlowTest, FaultyProjectPartPchForCreatesFaultyPchForPchTask)
|
TEST_F(PchCreatorVerySlowTest, FaultyProjectPartPchForCreatesFaultyPchForPchTask)
|
||||||
{
|
{
|
||||||
PchTask faultyPchTask{"faultyProjectPart",
|
PchTask faultyPchTask{"faultyProjectPart",
|
||||||
@@ -245,4 +254,12 @@ TEST_F(PchCreatorVerySlowTest, FaultyProjectPartPchForCreatesFaultyPchForPchTask
|
|||||||
Field(&ProjectPartPch::lastModified, Eq(-1))));
|
Field(&ProjectPartPch::lastModified, Eq(-1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PchCreatorVerySlowTest, GeneratedFile)
|
||||||
|
{
|
||||||
|
creator.clear();
|
||||||
|
|
||||||
|
creator.setUnsavedFiles({generatedFile});
|
||||||
|
|
||||||
|
ASSERT_FALSE(creator.clangTool().isClean());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user