Clang: Introduce CompilerMacro

We want not only the name but the value of the macro too. So we can
compare if anything has changed.

Change-Id: Ie59caf8cbf54d108f9e15299d25306a406b5c40d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-02-06 19:03:14 +01:00
parent 07fcd6f362
commit 56f79feebf
27 changed files with 251 additions and 77 deletions

View File

@@ -31,8 +31,9 @@
#include <sqlitetransaction.h>
#include <filepathcachingfwd.h>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
namespace ClangBackEnd {
@@ -67,25 +68,25 @@ public:
void insertOrUpdateProjectPart(Utils::SmallStringView projectPartName,
const Utils::SmallStringVector &commandLineArguments,
const Utils::SmallStringVector &macroNames) override
const CompilerMacros &compilerMacros) override
{
m_statementFactory.database.setLastInsertedRowId(-1);
Utils::SmallString compilerArguementsAsJson = toJson(commandLineArguments);
Utils::SmallString macroNamesAsJson = toJson(macroNames);
Utils::SmallString compilerMacrosAsJson = toJson(compilerMacros);
WriteStatement &insertStatement = m_statementFactory.insertProjectPartStatement;
insertStatement.write(projectPartName, compilerArguementsAsJson, macroNamesAsJson);
insertStatement.write(projectPartName, compilerArguementsAsJson, compilerMacrosAsJson);
if (m_statementFactory.database.lastInsertedRowId() == -1) {
WriteStatement &updateStatement = m_statementFactory.updateProjectPartStatement;
updateStatement.write(compilerArguementsAsJson, macroNamesAsJson, projectPartName);
updateStatement.write(compilerArguementsAsJson, compilerMacrosAsJson, projectPartName);
}
}
Utils::optional<ProjectPartArtefact> fetchProjectPartArtefact(FilePathId sourceId) const override
{
ReadStatement &statement = m_statementFactory.getProjectPartCompilerArgumentsAndMacroNames;
ReadStatement &statement = m_statementFactory.getProjectPartCompilerArgumentsAndCompilerMacrosBySourceId;
return statement.template value<ProjectPartArtefact, 3>(sourceId.filePathId);
}
@@ -157,6 +158,19 @@ public:
return document.toJson(QJsonDocument::Compact);
}
static Utils::SmallString toJson(const CompilerMacros &compilerMacros)
{
QJsonDocument document;
QJsonObject object;
for (const CompilerMacro &macro : compilerMacros)
object.insert(QString(macro.key), QString(macro.value));
document.setObject(object);
return document.toJson(QJsonDocument::Compact);
}
void fillTemporarySymbolsTable(const SymbolEntries &symbolEntries)
{
WriteStatement &statement = m_statementFactory.insertSymbolsToNewSymbolsStatement;