Clang: Store UsedDefines in the symbol database

We write the new defines in a temporary table and then write every new
entry in the usedDefines table, followed by remove of every entry in
usedDefines which are not in the temporary table but have a file entry in
common with one of the entries in the temporary table. At last we clean up
the temporary table.

Change-Id: Idf11ce8d17ad9ccef490578059fac08409fcc5d9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-01-24 18:06:15 +01:00
parent 5cd64e8049
commit b247c4fdeb
6 changed files with 99 additions and 15 deletions

View File

@@ -108,7 +108,7 @@ TEST_F(RefactoringDatabaseInitializer, AddUsedDefinesTable)
InSequence s;
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS usedDefines(usedDefineId INTEGER PRIMARY KEY, sourceId INTEGER, defineName TEXT)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedDefines_sourceId ON usedDefines(sourceId)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedDefines_sourceId_defineName ON usedDefines(sourceId, defineName)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedDefines_defineName ON usedDefines(defineName)")));
initializer.createUsedDefinesTable();
@@ -133,7 +133,7 @@ TEST_F(RefactoringDatabaseInitializer, CreateInTheContructor)
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_projectPartsSources_sourceId_projectPartId ON projectPartsSources(sourceId, projectPartId)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_projectPartsSources_projectPartId ON projectPartsSources(projectPartId)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS usedDefines(usedDefineId INTEGER PRIMARY KEY, sourceId INTEGER, defineName TEXT)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedDefines_sourceId ON usedDefines(sourceId)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedDefines_sourceId_defineName ON usedDefines(sourceId, defineName)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_usedDefines_defineName ON usedDefines(defineName)")));
EXPECT_CALL(mockDatabase, commit());