diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 46373deb80c..a6c5be31655 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -808,6 +808,7 @@ QString simplifySTLType(const QString &typeIn) if (type.startsWith(QLatin1String("struct "))) type.remove(0, 7); + const bool isLibCpp = type.contains(QLatin1String("std::__1")); type.replace(QLatin1String("std::__1::"), QLatin1String("std::")); type.replace(QLatin1String("std::__debug::"), QLatin1String("std::")); type.replace(QLatin1Char('*'), QLatin1Char('@')); @@ -849,6 +850,7 @@ QString simplifySTLType(const QString &typeIn) } const QString alloc = fixNestedTemplates(type.mid(start, pos + 1 - start).trimmed()); const QString inner = fixNestedTemplates(alloc.mid(15, alloc.size() - 16).trimmed()); + const QString allocEsc = QRegExp::escape(alloc); const QString innerEsc = QRegExp::escape(inner); if (inner == QLatin1String("char")) { // std::string @@ -871,6 +873,13 @@ QString simplifySTLType(const QString &typeIn) if (stackRE.indexIn(type) != -1) type.replace(stackRE.cap(0), QString::fromLatin1("stack<%1>").arg(inner)); + // std::hash + QRegExp hashCharRE(QString::fromLatin1("hash, ?%1\\s*>").arg(allocEsc)); + hashCharRE.setMinimal(true); + QTC_ASSERT(hashCharRE.isValid(), return typeIn); + if (hashCharRE.indexIn(type) != -1) + type.replace(hashCharRE.cap(0), QString::fromLatin1("hash")); + // std::set QRegExp setRE(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(innerEsc, innerEsc, allocEsc)); setRE.setMinimal(true); @@ -949,6 +958,15 @@ QString simplifySTLType(const QString &typeIn) 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)); + + if (isLibCpp) { + QRegExp mapRE2(QString::fromLatin1("unordered_map, ?std::equal_to, ?%2\\s*>") + .arg(valueEsc, allocEsc)); + mapRE2.setMinimal(true); + QTC_ASSERT(mapRE2.isValid(), return typeIn); + if (mapRE2.indexIn(type) != -1) + type.replace(mapRE2.cap(0), QString::fromLatin1("unordered_map").arg(value)); + } } } type.replace(QLatin1Char('@'), QLatin1Char('*')); diff --git a/tests/auto/debugger/tst_simplifytypes.cpp b/tests/auto/debugger/tst_simplifytypes.cpp index 2e8adc1a1ad..cdd8273697f 100644 --- a/tests/auto/debugger/tst_simplifytypes.cpp +++ b/tests/auto/debugger/tst_simplifytypes.cpp @@ -49,6 +49,7 @@ const char *description[] = "g++_unordered_map", "libc++_stringvector", + "libc++_unordered_map", "msvc_stdstring", "msvc_stdwstring", @@ -80,6 +81,8 @@ const char *input[] = // libc++ "std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >", +"std::__1::unordered_map, std::__1::allocator >, float, std::__1::hash, std::__1::allocator >, std::__1::equal_to, std::__1::allocator > >, std::__1::allocator, std::__1::allocator >, float> > >", + // MSVC "class std::basic_string,std::allocator >", "class std::basic_string,std::allocator >", @@ -110,6 +113,7 @@ const char *output[] = "std::unordered_map", // libc++ "std::vector", + "std::unordered_map", // MSVC "std::string", "std::wstring",