From dd366b68dea11eebb0b1c53f3cff1902ce2bfefa Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 17 Dec 2018 12:06:57 +0100 Subject: PchManager: Split pch tasks in project and system pch tasks Like you can see in the task numbers this patch is touching many different areas. So I will only touch the main parts. It is using a clang action instead of an extra process which will be enabling the handling of generated files in PCHs. The flags from the project part are now not anymore transformed in a command line but they are saved in the container semantically aware so that they can later be merged. Most of this patch is simply polishing of other patches. Task-number: QTCREATORBUG-21346 Task-number: QTCREATORBUG-21380 Task-number: QTCREATORBUG-21382 Task-number: QTCREATORBUG-21383 Task-number: QTCREATORBUG-21693 Task-number: QTCREATORBUG-21778 Change-Id: I9b0c02d8149b554254e819448fbc61eeaa5b7494 Reviewed-by: Ivan Donchevskii --- .../source/projectpartartefact.cpp | 52 +++++++++++++++------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'src/tools/clangrefactoringbackend/source/projectpartartefact.cpp') diff --git a/src/tools/clangrefactoringbackend/source/projectpartartefact.cpp b/src/tools/clangrefactoringbackend/source/projectpartartefact.cpp index 13856e1411..1c62bec8fe 100644 --- a/src/tools/clangrefactoringbackend/source/projectpartartefact.cpp +++ b/src/tools/clangrefactoringbackend/source/projectpartartefact.cpp @@ -33,16 +33,7 @@ namespace ClangBackEnd { -ProjectPartArtefact::ProjectPartArtefact(Utils::SmallStringView compilerArgumentsText, - Utils::SmallStringView compilerMacrosText, - Utils::SmallStringView includeSearchPaths, - int projectPartId) - : compilerArguments(toStringVector(compilerArgumentsText)), - compilerMacros(toCompilerMacros(compilerMacrosText)), - includeSearchPaths(toStringVector(includeSearchPaths)), - projectPartId(projectPartId) -{ -} + Utils::SmallStringVector ProjectPartArtefact::toStringVector(Utils::SmallStringView jsonText) { @@ -58,19 +49,35 @@ Utils::SmallStringVector ProjectPartArtefact::toStringVector(Utils::SmallStringV CompilerMacros ProjectPartArtefact::createCompilerMacrosFromDocument(const QJsonDocument &document) { - QJsonObject object = document.object(); + QJsonArray array = document.array(); CompilerMacros macros; - macros.reserve(object.size()); + macros.reserve(array.size()); - int index = 0; - for (auto current = object.constBegin(); current != object.constEnd(); ++current) - macros.emplace_back(current.key(), current.value().toString(), ++index); + for (const QJsonValueRef entry : array) { + const QJsonArray entryArray = entry.toArray(); + macros.emplace_back( + entryArray[0].toString(), entryArray[1].toString(), entryArray[2].toInt()); + } std::sort(macros.begin(), macros.end()); return macros; } +IncludeSearchPaths ProjectPartArtefact::createIncludeSearchPathsFromDocument(const QJsonDocument &document) +{ + QJsonArray array = document.array(); + IncludeSearchPaths paths; + paths.reserve(array.size()); + + for (const QJsonValueRef entry : array) { + const QJsonArray entryArray = entry.toArray(); + paths.emplace_back(entryArray[0].toString(), entryArray[1].toInt(), entryArray[2].toInt()); + } + + return paths; +} + CompilerMacros ProjectPartArtefact::toCompilerMacros(Utils::SmallStringView jsonText) { if (jsonText.isEmpty()) @@ -93,6 +100,17 @@ QJsonDocument ProjectPartArtefact::createJsonDocument(Utils::SmallStringView jso return document; } +IncludeSearchPaths ProjectPartArtefact::toIncludeSearchPaths(Utils::SmallStringView jsonText) +{ + + if (jsonText.isEmpty()) + return {}; + + QJsonDocument document = createJsonDocument(jsonText, "Include search paths parsing error"); + + return createIncludeSearchPathsFromDocument(document); +} + void ProjectPartArtefact::checkError(const char *whatError, const QJsonParseError &error) { if (error.error != QJsonParseError::NoError) { @@ -104,7 +122,9 @@ void ProjectPartArtefact::checkError(const char *whatError, const QJsonParseErro bool operator==(const ProjectPartArtefact &first, const ProjectPartArtefact &second) { return first.compilerArguments == second.compilerArguments - && first.compilerMacros == second.compilerMacros; + && first.compilerMacros == second.compilerMacros + && first.systemIncludeSearchPaths == second.systemIncludeSearchPaths + && first.projectIncludeSearchPaths == second.projectIncludeSearchPaths; } } // namespace ClangBackEnd -- cgit v1.2.1