forked from qt-creator/qt-creator
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:
@@ -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 ¯oNames) 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 ¯o : 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;
|
||||
|
||||
Reference in New Issue
Block a user