aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/clangsupport
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-01-30 18:48:59 +0100
committerMarco Bubke <marco.bubke@qt.io>2019-02-05 11:07:14 +0000
commit0082a82fc62fef78b64558faf70a7691452bb1f3 (patch)
treeb34159ee79534586727a0bc9cba9d861b7e27e5b /src/libs/clangsupport
parent14a44948d87f9ff0de1e6963fb6ed10fd994f101 (diff)
ClangPchManager: Merge system pch tasks
The merging of the include search paths is quite heuristic but we could provide an option to disable pch merging so users can decide themselves. Maybe we could give user feedback why we cannot merge but this is quite advanced. Task-number: QTCREATORBUG-21381 Change-Id: Iac6af0c587b631d2151f63d6d97215ed6919819f Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/libs/clangsupport')
-rw-r--r--src/libs/clangsupport/commandlinebuilder.h7
-rw-r--r--src/libs/clangsupport/compilermacro.h28
2 files changed, 31 insertions, 4 deletions
diff --git a/src/libs/clangsupport/commandlinebuilder.h b/src/libs/clangsupport/commandlinebuilder.h
index 6a9975a3ac9..df116197ab1 100644
--- a/src/libs/clangsupport/commandlinebuilder.h
+++ b/src/libs/clangsupport/commandlinebuilder.h
@@ -182,6 +182,13 @@ public:
{
CompilerMacros macros = compilerMacros;
+ macros.erase(std::remove_if(macros.begin(),
+ macros.end(),
+ [](const auto &macro) {
+ return macro.type == CompilerMacroType::NotDefined;
+ }),
+ macros.end());
+
std::sort(macros.begin(),
macros.end(),
[](const CompilerMacro &first, const CompilerMacro &second) {
diff --git a/src/libs/clangsupport/compilermacro.h b/src/libs/clangsupport/compilermacro.h
index ddba1a40762..798bab2ebd7 100644
--- a/src/libs/clangsupport/compilermacro.h
+++ b/src/libs/clangsupport/compilermacro.h
@@ -31,6 +31,8 @@
namespace ClangBackEnd {
+enum class CompilerMacroType : unsigned char { Define, NotDefined };
+
class CompilerMacro
{
public:
@@ -40,39 +42,57 @@ public:
: key(std::move(key))
, value(std::move(value))
, index(index)
+ , type(CompilerMacroType::Define)
+ {}
+
+ CompilerMacro(Utils::SmallString &&key)
+ : key(std::move(key))
+ {}
+
+ CompilerMacro(const Utils::SmallString &key)
+ : key(key)
{}
friend QDataStream &operator<<(QDataStream &out, const CompilerMacro &compilerMacro)
{
out << compilerMacro.key;
out << compilerMacro.value;
+ out << compilerMacro.index;
+ out << static_cast<unsigned char>(compilerMacro.type);
return out;
}
friend QDataStream &operator>>(QDataStream &in, CompilerMacro &compilerMacro)
{
+ unsigned char type;
+
in >> compilerMacro.key;
in >> compilerMacro.value;
+ in >> compilerMacro.index;
+ in >> type;
+
+ compilerMacro.type = static_cast<CompilerMacroType>(type);
return in;
}
friend bool operator==(const CompilerMacro &first, const CompilerMacro &second)
{
- return first.key == second.key
- && first.value == second.value;
+ return first.key == second.key && first.value == second.value && first.type == second.type;
}
friend bool operator<(const CompilerMacro &first, const CompilerMacro &second)
{
- return std::tie(first.key, first.value) < std::tie(second.key, second.value);
+ return std::tie(first.key, first.type, first.value)
+ < std::tie(second.key, second.type, second.value);
}
public:
Utils::SmallString key;
Utils::SmallString value;
- int index = 0;
+ int index = -1;
+ CompilerMacroType type = CompilerMacroType::NotDefined;
};
using CompilerMacros = std::vector<CompilerMacro>;