diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 46373deb80c1a75a35d690d19e2d9f5ffb7db934..a6c5be31655c9a861658faec3e1dc6540d0c65d3 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<char> + QRegExp hashCharRE(QString::fromLatin1("hash<char, std::char_traits<char>, ?%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<char>")); + // 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::string, ?%1, ?std::hash<char>, ?std::equal_to<std::string>, ?%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<std::string, %2>").arg(value)); + } } } type.replace(QLatin1Char('@'), QLatin1Char('*')); diff --git a/tests/auto/debugger/tst_simplifytypes.cpp b/tests/auto/debugger/tst_simplifytypes.cpp index 2e8adc1a1ad4a3fac65d2f7020b1053afb732e37..cdd8273697f1c8d4316b3c40321e3a27d31d1854 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::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >", +"std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float, std::__1::hash<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float> > >", + // MSVC "class std::basic_string<char,std::char_traits<char>,std::allocator<char> >", "class std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >", @@ -110,6 +113,7 @@ const char *output[] = "std::unordered_map<int, int>", // libc++ "std::vector<std::string>", + "std::unordered_map<std::string, float>", // MSVC "std::string", "std::wstring",