aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/cplusplus/CppRewriter.cpp
diff options
context:
space:
mode:
authorhjk <[email protected]>2013-08-16 00:44:26 +0200
committerDavid Schulz <[email protected]>2013-08-16 11:11:21 +0200
commit958a1d2d4ec1b5c4d8f09684313c31050cc8d86c (patch)
treee91cd91e3db01fda7a2a20e3f63abb4fa9c05ec6 /src/libs/cplusplus/CppRewriter.cpp
parentcb4c649ac0e5ce7c1fc340965e81a211415af121 (diff)
Debugger: Implement dumper for std::unordered_{set,map}
Task-number: QTCREATORBUG-9855 Change-Id: I985745530d93e1c191442431a7a9449a1c4c059a Reviewed-by: hjk <[email protected]> Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/libs/cplusplus/CppRewriter.cpp')
-rw-r--r--src/libs/cplusplus/CppRewriter.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp
index 65191194e26..5920a8e605f 100644
--- a/src/libs/cplusplus/CppRewriter.cpp
+++ b/src/libs/cplusplus/CppRewriter.cpp
@@ -586,6 +586,14 @@ CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn)
if (setRE.indexIn(type) != -1)
type.replace(setRE.cap(0), QString::fromLatin1("set<%1>").arg(inner));
+ // std::unordered_set
+ QRegExp unorderedSetRE(QString::fromLatin1("unordered_set<%1, ?std::hash<%2>, ?std::equal_to<%3>, ?%4\\s*>")
+ .arg(innerEsc, innerEsc, innerEsc, allocEsc));
+ unorderedSetRE.setMinimal(true);
+ QTC_ASSERT(unorderedSetRE.isValid(), return typeIn);
+ if (unorderedSetRE.indexIn(type) != -1)
+ type.replace(unorderedSetRE.cap(0), QString::fromLatin1("unordered_set<%1>").arg(inner));
+
// std::map
if (inner.startsWith(QLatin1String("std::pair<"))) {
// search for outermost ',', split key and value
@@ -621,6 +629,35 @@ CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn)
type.replace(mapRE2.cap(0), QString::fromLatin1("map<const %1, %2>").arg(key, value));
}
}
+
+ // std::unordered_map
+ if (inner.startsWith(QLatin1String("std::pair<"))) {
+ // search for outermost ',', split key and value
+ int pos;
+ int level = 0;
+ for (pos = 10; pos < inner.size(); ++pos) {
+ int c = inner.at(pos).unicode();
+ if (c == '<')
+ ++level;
+ else if (c == '>')
+ --level;
+ else if (c == ',' && level == 0)
+ break;
+ }
+ const QString key = chopConst(inner.mid(10, pos - 10));
+ const QString keyEsc = QRegExp::escape(key);
+ // Get value: MSVC: 'pair<a const ,b>', gcc: 'pair<const a, b>'
+ if (inner.at(++pos) == QLatin1Char(' '))
+ pos++;
+ const QString value = inner.mid(pos, inner.size() - pos - 1).trimmed();
+ const QString valueEsc = QRegExp::escape(value);
+ QRegExp mapRE1(QString::fromLatin1("unordered_map<%1, ?%2, ?std::hash<%3 ?>, ?std::equal_to<%4 ?>, ?%5\\s*>")
+ .arg(keyEsc, valueEsc, keyEsc, keyEsc, allocEsc));
+ mapRE1.setMinimal(true);
+ QTC_ASSERT(mapRE1.isValid(), return typeIn);
+ if (mapRE1.indexIn(type) != -1)
+ type.replace(mapRE1.cap(0), QString::fromLatin1("unordered_map<%1, %2>").arg(key, value));
+ }
}
type.replace(QLatin1Char('@'), QLatin1Char('*'));
type.replace(QLatin1String(" >"), QLatin1String(">"));