diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-02-06 19:03:14 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-02-15 09:58:53 +0000 |
commit | 56f79feebfa8d403be50ab8faf99da03376016b8 (patch) | |
tree | 24e599c3a800cf4db8d491d6a1c4033411608b9e /src/tools/clangrefactoringbackend/source/symbolstorage.h | |
parent | 07fcd6f3628a65f4a88ce6f228f75972c96973e2 (diff) | |
download | qt-creator-56f79feebfa8d403be50ab8faf99da03376016b8.tar.gz |
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>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolstorage.h')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/symbolstorage.h | 26 |
1 files changed, 20 insertions, 6 deletions
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 <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; |