forked from qt-creator/qt-creator
Clang: Add isInPrecompiledHeader to the file status table
It will useful to find out if we have to wait for an updated precompiled header. Change-Id: I6a314f278485965571cc6e46982bbd6f5523c581 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -157,7 +157,7 @@ public:
|
||||
table.addColumn("sourceId", Sqlite::ColumnType::Integer, Sqlite::Contraint::PrimaryKey);
|
||||
table.addColumn("size", Sqlite::ColumnType::Integer);
|
||||
table.addColumn("lastModified", Sqlite::ColumnType::Integer);
|
||||
|
||||
table.addColumn("isInPrecompiledHeader", Sqlite::ColumnType::Integer);
|
||||
table.initialize(database);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class PchManagerClient;
|
||||
class PchManagerNotifierInterface
|
||||
{
|
||||
public:
|
||||
PchManagerNotifierInterface(PchManagerClient &pchManagerClient);
|
||||
PchManagerNotifierInterface(PchManagerClient &pchManagerClientso);
|
||||
|
||||
virtual ~PchManagerNotifierInterface();
|
||||
virtual void precompiledHeaderUpdated(const QString &projectPartId,
|
||||
|
||||
@@ -76,9 +76,7 @@ public:
|
||||
const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(
|
||||
m_sourceManager.getFileID(sourceLocation));
|
||||
if (fileEntry) {
|
||||
m_fileStatuses.emplace_back(filePathId(fileEntry),
|
||||
fileEntry->getSize(),
|
||||
fileEntry->getModificationTime());
|
||||
addFileStatus(fileEntry);
|
||||
addSourceFile(fileEntry);
|
||||
}
|
||||
}
|
||||
@@ -258,16 +256,36 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void addSourceFile(const clang::FileEntry *file)
|
||||
void addSourceFile(const clang::FileEntry *fileEntry)
|
||||
{
|
||||
auto id = filePathId(file);
|
||||
auto id = filePathId(fileEntry);
|
||||
|
||||
auto found = std::find(m_sourceFiles.begin(), m_sourceFiles.end(), id);
|
||||
auto found = std::lower_bound(m_sourceFiles.begin(), m_sourceFiles.end(), id);
|
||||
|
||||
if (found == m_sourceFiles.end() || *found != id)
|
||||
m_sourceFiles.insert(found, id);
|
||||
}
|
||||
|
||||
void addFileStatus(const clang::FileEntry *fileEntry)
|
||||
{
|
||||
auto id = filePathId(fileEntry);
|
||||
|
||||
auto found = std::lower_bound(m_fileStatuses.begin(),
|
||||
m_fileStatuses.end(),
|
||||
id,
|
||||
[] (const auto &first, const auto &second) {
|
||||
return first.filePathId < second;
|
||||
});
|
||||
|
||||
if (found == m_fileStatuses.end() || found->filePathId != id) {
|
||||
m_fileStatuses.emplace(found,
|
||||
id,
|
||||
fileEntry->getSize(),
|
||||
fileEntry->getModificationTime(),
|
||||
fileEntry->isInPCH());
|
||||
}
|
||||
}
|
||||
|
||||
void addSourceDependency(const clang::FileEntry *file, clang::SourceLocation includeLocation)
|
||||
{
|
||||
auto includeFilePathId = filePathId(includeLocation);
|
||||
|
||||
@@ -37,11 +37,13 @@ class FileStatus
|
||||
{
|
||||
public:
|
||||
FileStatus(FilePathId filePathId,
|
||||
off_t size,
|
||||
std::time_t lastModified)
|
||||
off_t size,
|
||||
std::time_t lastModified,
|
||||
bool isInPrecompiledHeader)
|
||||
: filePathId(filePathId),
|
||||
size(size),
|
||||
lastModified(lastModified)
|
||||
lastModified(lastModified),
|
||||
isInPrecompiledHeader(isInPrecompiledHeader)
|
||||
{}
|
||||
|
||||
friend
|
||||
@@ -56,6 +58,7 @@ public:
|
||||
FilePathId filePathId;
|
||||
off_t size;
|
||||
std::time_t lastModified;
|
||||
bool isInPrecompiledHeader;
|
||||
};
|
||||
|
||||
using FileStatuses = std::vector<FileStatus>;
|
||||
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
database
|
||||
};
|
||||
WriteStatement insertFileStatuses{
|
||||
"INSERT OR REPLACE INTO fileStatuses(sourceId, size, lastModified) VALUES (?,?,?)",
|
||||
"INSERT OR REPLACE INTO fileStatuses(sourceId, size, lastModified, isInPrecompiledHeader) VALUES (?,?,?,?)",
|
||||
database
|
||||
};
|
||||
WriteStatement insertIntoNewSourceDependenciesStatement{
|
||||
|
||||
@@ -156,7 +156,8 @@ public:
|
||||
for (const FileStatus &fileStatus : fileStatuses)
|
||||
statement.write(fileStatus.filePathId.filePathId,
|
||||
fileStatus.size,
|
||||
fileStatus.lastModified);
|
||||
fileStatus.lastModified,
|
||||
fileStatus.isInPrecompiledHeader);
|
||||
}
|
||||
|
||||
static Utils::SmallString toJson(const Utils::SmallStringVector &strings)
|
||||
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
MOCK_METHOD4(write,
|
||||
void (uint, uint, uint, uint));
|
||||
|
||||
MOCK_METHOD4(write,
|
||||
void (long long, int, int, int));
|
||||
|
||||
MOCK_METHOD2(write,
|
||||
void (uint, Utils::SmallStringView));
|
||||
|
||||
@@ -82,6 +85,9 @@ public:
|
||||
MOCK_METHOD3(write,
|
||||
void (uint, uint, uint));
|
||||
|
||||
MOCK_METHOD4(write,
|
||||
void (int, off_t, time_t, bool));
|
||||
|
||||
MOCK_METHOD2(write,
|
||||
void (uint, uint));
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ TEST_F(RefactoringDatabaseInitializer, AddFileStatusesTable)
|
||||
{
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS fileStatuses(sourceId INTEGER PRIMARY KEY, size INTEGER, lastModified INTEGER)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS fileStatuses(sourceId INTEGER PRIMARY KEY, size INTEGER, lastModified INTEGER, isInPrecompiledHeader INTEGER)")));
|
||||
|
||||
initializer.createFileStatusesTable();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ TEST_F(RefactoringDatabaseInitializer, CreateInTheContructor)
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS usedMacros(usedMacroId INTEGER PRIMARY KEY, sourceId INTEGER, macroName TEXT)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedMacros_sourceId_macroName ON usedMacros(sourceId, macroName)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedMacros_macroName ON usedMacros(macroName)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS fileStatuses(sourceId INTEGER PRIMARY KEY, size INTEGER, lastModified INTEGER)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS fileStatuses(sourceId INTEGER PRIMARY KEY, size INTEGER, lastModified INTEGER, isInPrecompiledHeader INTEGER)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS sourceDependencies(sourceId INTEGER, dependencySourceId INTEGER)")));
|
||||
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_sourceDependencies_sourceId_dependencySourceId ON sourceDependencies(sourceId, dependencySourceId)")));
|
||||
EXPECT_CALL(mockDatabase, commit());
|
||||
|
||||
@@ -229,7 +229,7 @@ TEST_F(StorageSqliteStatementFactory, DeleteAllInNewUnusedMacros)
|
||||
TEST_F(StorageSqliteStatementFactory, InsertFileStatuses)
|
||||
{
|
||||
ASSERT_THAT(factory.insertFileStatuses.sqlStatement,
|
||||
Eq("INSERT OR REPLACE INTO fileStatuses(sourceId, size, lastModified) VALUES (?,?,?)"));
|
||||
Eq("INSERT OR REPLACE INTO fileStatuses(sourceId, size, lastModified, isInPrecompiledHeader) VALUES (?,?,?,?)"));
|
||||
}
|
||||
|
||||
TEST_F(StorageSqliteStatementFactory, InsertIntoNewSourceDependencies)
|
||||
|
||||
@@ -100,7 +100,7 @@ protected:
|
||||
SourceLocationEntries sourceLocations{{1, {1, 1}, {42, 23}, SymbolType::Declaration}};
|
||||
FilePathIds sourceFileIds{{1, 1}, {42, 23}};
|
||||
UsedMacros usedMacros{{"Foo", {1, 1}}};
|
||||
FileStatuses fileStatus{{{1, 2}, 3, 4}};
|
||||
FileStatuses fileStatus{{{1, 2}, 3, 4, false}};
|
||||
SourceDependencies sourceDependencies{{{1, 1}, {1, 2}}, {{1, 1}, {1, 3}}};
|
||||
ClangBackEnd::ProjectPartArtefact artefact{"[\"-DFOO\"]", "{\"FOO\":\"1\",\"BAR\":\"1\"}", "[\"/includes\"]", 74};
|
||||
NiceMock<MockSqliteTransactionBackend> mockSqliteTransactionBackend;
|
||||
|
||||
@@ -117,7 +117,7 @@ protected:
|
||||
|
||||
ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const
|
||||
{
|
||||
return {filePathId(filePath), fileSize(filePath), lastModified(filePath)};
|
||||
return {filePathId(filePath), fileSize(filePath), lastModified(filePath), false};
|
||||
}
|
||||
|
||||
SymbolIndex symbolId(const Utils::SmallString &symbolName)
|
||||
|
||||
@@ -40,12 +40,14 @@
|
||||
namespace {
|
||||
|
||||
using Utils::PathString;
|
||||
using ClangBackEnd::FilePathId;
|
||||
using ClangBackEnd::FilePathCachingInterface;
|
||||
using ClangBackEnd::SymbolEntries;
|
||||
using ClangBackEnd::SymbolEntry;
|
||||
using ClangBackEnd::SourceLocationEntries;
|
||||
using ClangBackEnd::SourceLocationEntry;
|
||||
using ClangBackEnd::StorageSqliteStatementFactory;
|
||||
using ClangBackEnd::SymbolIndex;
|
||||
using ClangBackEnd::SymbolType;
|
||||
using Sqlite::Database;
|
||||
using Sqlite::Table;
|
||||
@@ -99,8 +101,8 @@ TEST_F(SymbolStorage, CreateAndFillTemporaryLocationsTable)
|
||||
{
|
||||
InSequence sequence;
|
||||
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(1, 42, 23, 3));
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(2, 7, 11, 4));
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(TypedEq<SymbolIndex>(1), TypedEq<int>(42), TypedEq<int>(23), TypedEq<int>(3)));
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(TypedEq<SymbolIndex>(2), TypedEq<int>(7), TypedEq<int>(11), TypedEq<int>(4)));
|
||||
|
||||
storage.fillTemporaryLocationsTable(sourceLocations);
|
||||
}
|
||||
@@ -159,8 +161,8 @@ TEST_F(SymbolStorage, AddSymbolsAndSourceLocationsCallsWrite)
|
||||
InSequence sequence;
|
||||
|
||||
EXPECT_CALL(insertSymbolsToNewSymbolsStatement, write(An<uint>(), An<Utils::SmallStringView>(), _)).Times(2);
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(1, 42, 23, 3));
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(2, 7, 11, 4));
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(TypedEq<SymbolIndex>(1), TypedEq<int>(42), TypedEq<int>(23), TypedEq<int>(3)));
|
||||
EXPECT_CALL(insertLocationsToNewLocationsStatement, write(TypedEq<SymbolIndex>(2), TypedEq<int>(7), TypedEq<int>(11), TypedEq<int>(4)));
|
||||
EXPECT_CALL(addNewSymbolsToSymbolsStatement, execute());
|
||||
EXPECT_CALL(syncNewSymbolsFromSymbolsStatement, execute());
|
||||
EXPECT_CALL(syncSymbolsIntoNewLocationsStatement, execute());
|
||||
@@ -245,10 +247,10 @@ TEST_F(SymbolStorage, InsertOrUpdateUsedMacros)
|
||||
|
||||
TEST_F(SymbolStorage, InsertFileStatuses)
|
||||
{
|
||||
EXPECT_CALL(insertFileStatuses, write(TypedEq<uint>(42), TypedEq<uint>(1), TypedEq<uint>(2)));
|
||||
EXPECT_CALL(insertFileStatuses, write(TypedEq<uint>(43), TypedEq<uint>(4), TypedEq<uint>(5)));
|
||||
EXPECT_CALL(insertFileStatuses, write(TypedEq<int>(42), TypedEq<off_t>(1), TypedEq<time_t>(2), TypedEq<bool>(false)));
|
||||
EXPECT_CALL(insertFileStatuses, write(TypedEq<int>(43), TypedEq<off_t>(4), TypedEq<time_t>(5), TypedEq<bool>(true)));
|
||||
|
||||
storage.insertFileStatuses({{{1, 42}, 1, 2}, {{1, 43}, 4, 5}});
|
||||
storage.insertFileStatuses({{{1, 42}, 1, 2, false}, {{1, 43}, 4, 5, true}});
|
||||
}
|
||||
|
||||
TEST_F(SymbolStorage, InsertOrUpdateSourceDependencies)
|
||||
|
||||
Reference in New Issue
Block a user