From 56f79feebfa8d403be50ab8faf99da03376016b8 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Tue, 6 Feb 2018 19:03:14 +0100 Subject: 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 --- .../clangrefactoringbackend/source/symbolstorage.h | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/tools/clangrefactoringbackend/source/symbolstorage.h') diff --git a/src/tools/clangrefactoringbackend/source/symbolstorage.h b/src/tools/clangrefactoringbackend/source/symbolstorage.h index adf2afdef9..5445a82f80 100644 --- a/src/tools/clangrefactoringbackend/source/symbolstorage.h +++ b/src/tools/clangrefactoringbackend/source/symbolstorage.h @@ -31,8 +31,9 @@ #include #include -#include #include +#include +#include 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 fetchProjectPartArtefact(FilePathId sourceId) const override { - ReadStatement &statement = m_statementFactory.getProjectPartCompilerArgumentsAndMacroNames; + ReadStatement &statement = m_statementFactory.getProjectPartCompilerArgumentsAndCompilerMacrosBySourceId; return statement.template value(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; -- cgit v1.2.1