diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index 8816ba1d93d..4b6ba9a4374 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -40,14 +40,8 @@ #include #include -#include #include -#define QTC_ASSERT_STRINGIFY_HELPER(x) #x -#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x) -#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__)) -#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0) - namespace CPlusPlus { class Rewrite @@ -448,221 +442,4 @@ const Name *rewriteName(const Name *name, return rewrite.rewriteName(name); } -// Simplify complicated STL template types, -// such as 'std::basic_string,std::allocator >' -// -> 'std::string' and helpers. - -static QString chopConst(QString type) -{ - while (1) { - if (type.startsWith(QLatin1String("const"))) - type = type.mid(5); - else if (type.startsWith(QLatin1Char(' '))) - type = type.mid(1); - else if (type.endsWith(QLatin1String("const"))) - type.chop(5); - else if (type.endsWith(QLatin1Char(' '))) - type.chop(1); - else - break; - } - return type; -} - -static inline QRegExp stdStringRegExp(const QString &charType) -{ - QString rc = QLatin1String("basic_string<"); - rc += charType; - rc += QLatin1String(",[ ]?std::char_traits<"); - rc += charType; - rc += QLatin1String(">,[ ]?std::allocator<"); - rc += charType; - rc += QLatin1String("> >"); - const QRegExp re(rc); - QTC_ASSERT(re.isValid(), /**/); - return re; -} - -// Simplify string types in a type -// 'std::set >' -> std::set' -static inline void simplifyStdString(const QString &charType, const QString &replacement, - QString *type) -{ - QRegExp stringRegexp = stdStringRegExp(charType); - const int replacementSize = replacement.size(); - for (int pos = 0; pos < type->size(); ) { - // Check next match - const int matchPos = stringRegexp.indexIn(*type, pos); - if (matchPos == -1) - break; - const int matchedLength = stringRegexp.matchedLength(); - type->replace(matchPos, matchedLength, replacement); - pos = matchPos + replacementSize; - // If we were inside an 'allocator >' - // kill the following blank -> 'allocator' - if (pos + 1 < type->size() && type->at(pos) == QLatin1Char(' ') - && type->at(pos + 1) == QLatin1Char('>')) - type->remove(pos, 1); - } -} - -// Fix 'std::allocator' -> 'std::allocator', -// which can happen when replacing/simplifying -static inline QString fixNestedTemplates(QString s) -{ - const int size = s.size(); - if (size > 3 - && s.at(size - 1) == QLatin1Char('>') - && s.at(size - 2) == QLatin1Char(' ') - && s.at(size - 3) != QLatin1Char('>')) - s.remove(size - 2, 1); - return s; -} - -CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn) -{ - QString type = typeIn; - if (type.startsWith(QLatin1String("class "))) // MSVC prepends class,struct - type.remove(0, 6); - if (type.startsWith(QLatin1String("struct "))) - type.remove(0, 7); - - type.replace(QLatin1String("std::__1::"), QLatin1String("std::")); - type.replace(QLatin1String("std::__debug::"), QLatin1String("std::")); - type.replace(QLatin1Char('*'), QLatin1Char('@')); - - for (int i = 0; i < 10; ++i) { - // std::ifstream - QRegExp ifstreamRE(QLatin1String("std::basic_ifstream\\s*>")); - ifstreamRE.setMinimal(true); - QTC_ASSERT(ifstreamRE.isValid(), return typeIn); - if (ifstreamRE.indexIn(type) != -1) - type.replace(ifstreamRE.cap(0), QLatin1String("std::ifstream")); - - // Anything with a std::allocator - int start = type.indexOf(QLatin1String("std::allocator<")); - if (start == -1) - break; - // search for matching '>' - int pos; - int level = 0; - for (pos = start + 12; pos < type.size(); ++pos) { - int c = type.at(pos).unicode(); - if (c == '<') { - ++level; - } else if (c == '>') { - --level; - if (level == 0) - break; - } - } - 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 - simplifyStdString(QLatin1String("char"), QLatin1String("string"), &type); - } else if (inner == QLatin1String("wchar_t")) { // std::wstring - simplifyStdString(QLatin1String("wchar_t"), QLatin1String("wstring"), &type); - } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC - simplifyStdString(QLatin1String("unsigned short"), QLatin1String("wstring"), &type); - } - // std::vector, std::deque, std::list - QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(innerEsc, allocEsc)); - QTC_ASSERT(re1.isValid(), return typeIn); - if (re1.indexIn(type) != -1) - type.replace(re1.cap(0), QString::fromLatin1("%1<%2>").arg(re1.cap(1), inner)); - - // std::stack - QRegExp stackRE(QString::fromLatin1("stack<%1, ?std::deque<%2> >").arg(innerEsc, innerEsc)); - stackRE.setMinimal(true); - QTC_ASSERT(stackRE.isValid(), return typeIn); - if (stackRE.indexIn(type) != -1) - type.replace(stackRE.cap(0), QString::fromLatin1("stack<%1>").arg(inner)); - - // std::set - QRegExp setRE(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(innerEsc, innerEsc, allocEsc)); - setRE.setMinimal(true); - QTC_ASSERT(setRE.isValid(), return 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 - 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', gcc: 'pair' - 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("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>") - .arg(keyEsc, valueEsc, keyEsc, allocEsc)); - mapRE1.setMinimal(true); - QTC_ASSERT(mapRE1.isValid(), return typeIn); - if (mapRE1.indexIn(type) != -1) { - type.replace(mapRE1.cap(0), QString::fromLatin1("map<%1, %2>").arg(key, value)); - } else { - QRegExp mapRE2(QString::fromLatin1("map, ?%4\\s*>") - .arg(keyEsc, valueEsc, keyEsc, allocEsc)); - mapRE2.setMinimal(true); - if (mapRE2.indexIn(type) != -1) - type.replace(mapRE2.cap(0), QString::fromLatin1("map").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', gcc: 'pair' - 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(">")); - return type; -} - } // namespace CPlusPlus diff --git a/src/libs/cplusplus/CppRewriter.h b/src/libs/cplusplus/CppRewriter.h index 8c787db4a99..a4c38a24435 100644 --- a/src/libs/cplusplus/CppRewriter.h +++ b/src/libs/cplusplus/CppRewriter.h @@ -113,11 +113,6 @@ CPLUSPLUS_EXPORT const Name *rewriteName(const Name *name, SubstitutionEnvironment *env, Control *control); -// Simplify complicated STL template types, such as -// 'std::basic_string,std::allocator > '-> -// 'std::string'. -CPLUSPLUS_EXPORT QString simplifySTLType(const QString &typeIn); - } // namespace CPlusPlus #endif // CPPREWRITER_H diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index 5e5ab738214..5423c81f036 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -33,12 +33,18 @@ #include #include #include +#include #if QT_VERSION >= 0x050200 #include #endif #include +#define QTC_ASSERT_STRINGIFY_HELPER(x) #x +#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x) +#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__)) +#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0) + namespace Debugger { namespace Internal { @@ -723,5 +729,221 @@ QString decodeData(const QByteArray &ba, int encoding) return QCoreApplication::translate("Debugger", ""); } +// Simplify complicated STL template types, +// such as 'std::basic_string,std::allocator >' +// -> 'std::string' and helpers. + +static QString chopConst(QString type) +{ + while (1) { + if (type.startsWith(QLatin1String("const"))) + type = type.mid(5); + else if (type.startsWith(QLatin1Char(' '))) + type = type.mid(1); + else if (type.endsWith(QLatin1String("const"))) + type.chop(5); + else if (type.endsWith(QLatin1Char(' '))) + type.chop(1); + else + break; + } + return type; +} + +static inline QRegExp stdStringRegExp(const QString &charType) +{ + QString rc = QLatin1String("basic_string<"); + rc += charType; + rc += QLatin1String(",[ ]?std::char_traits<"); + rc += charType; + rc += QLatin1String(">,[ ]?std::allocator<"); + rc += charType; + rc += QLatin1String("> >"); + const QRegExp re(rc); + QTC_ASSERT(re.isValid(), /**/); + return re; +} + +// Simplify string types in a type +// 'std::set >' -> std::set' +static inline void simplifyStdString(const QString &charType, const QString &replacement, + QString *type) +{ + QRegExp stringRegexp = stdStringRegExp(charType); + const int replacementSize = replacement.size(); + for (int pos = 0; pos < type->size(); ) { + // Check next match + const int matchPos = stringRegexp.indexIn(*type, pos); + if (matchPos == -1) + break; + const int matchedLength = stringRegexp.matchedLength(); + type->replace(matchPos, matchedLength, replacement); + pos = matchPos + replacementSize; + // If we were inside an 'allocator >' + // kill the following blank -> 'allocator' + if (pos + 1 < type->size() && type->at(pos) == QLatin1Char(' ') + && type->at(pos + 1) == QLatin1Char('>')) + type->remove(pos, 1); + } +} + +// Fix 'std::allocator' -> 'std::allocator', +// which can happen when replacing/simplifying +static inline QString fixNestedTemplates(QString s) +{ + const int size = s.size(); + if (size > 3 + && s.at(size - 1) == QLatin1Char('>') + && s.at(size - 2) == QLatin1Char(' ') + && s.at(size - 3) != QLatin1Char('>')) + s.remove(size - 2, 1); + return s; +} + +QString simplifySTLType(const QString &typeIn) +{ + QString type = typeIn; + if (type.startsWith(QLatin1String("class "))) // MSVC prepends class,struct + type.remove(0, 6); + if (type.startsWith(QLatin1String("struct "))) + type.remove(0, 7); + + type.replace(QLatin1String("std::__1::"), QLatin1String("std::")); + type.replace(QLatin1String("std::__debug::"), QLatin1String("std::")); + type.replace(QLatin1Char('*'), QLatin1Char('@')); + + for (int i = 0; i < 10; ++i) { + // std::ifstream + QRegExp ifstreamRE(QLatin1String("std::basic_ifstream\\s*>")); + ifstreamRE.setMinimal(true); + QTC_ASSERT(ifstreamRE.isValid(), return typeIn); + if (ifstreamRE.indexIn(type) != -1) + type.replace(ifstreamRE.cap(0), QLatin1String("std::ifstream")); + + // Anything with a std::allocator + int start = type.indexOf(QLatin1String("std::allocator<")); + if (start == -1) + break; + // search for matching '>' + int pos; + int level = 0; + for (pos = start + 12; pos < type.size(); ++pos) { + int c = type.at(pos).unicode(); + if (c == '<') { + ++level; + } else if (c == '>') { + --level; + if (level == 0) + break; + } + } + 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 + simplifyStdString(QLatin1String("char"), QLatin1String("string"), &type); + } else if (inner == QLatin1String("wchar_t")) { // std::wstring + simplifyStdString(QLatin1String("wchar_t"), QLatin1String("wstring"), &type); + } else if (inner == QLatin1String("unsigned short")) { // std::wstring/MSVC + simplifyStdString(QLatin1String("unsigned short"), QLatin1String("wstring"), &type); + } + // std::vector, std::deque, std::list + QRegExp re1(QString::fromLatin1("(vector|list|deque)<%1, ?%2\\s*>").arg(innerEsc, allocEsc)); + QTC_ASSERT(re1.isValid(), return typeIn); + if (re1.indexIn(type) != -1) + type.replace(re1.cap(0), QString::fromLatin1("%1<%2>").arg(re1.cap(1), inner)); + + // std::stack + QRegExp stackRE(QString::fromLatin1("stack<%1, ?std::deque<%2> >").arg(innerEsc, innerEsc)); + stackRE.setMinimal(true); + QTC_ASSERT(stackRE.isValid(), return typeIn); + if (stackRE.indexIn(type) != -1) + type.replace(stackRE.cap(0), QString::fromLatin1("stack<%1>").arg(inner)); + + // std::set + QRegExp setRE(QString::fromLatin1("set<%1, ?std::less<%2>, ?%3\\s*>").arg(innerEsc, innerEsc, allocEsc)); + setRE.setMinimal(true); + QTC_ASSERT(setRE.isValid(), return 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 + 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', gcc: 'pair' + 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("map<%1, ?%2, ?std::less<%3 ?>, ?%4\\s*>") + .arg(keyEsc, valueEsc, keyEsc, allocEsc)); + mapRE1.setMinimal(true); + QTC_ASSERT(mapRE1.isValid(), return typeIn); + if (mapRE1.indexIn(type) != -1) { + type.replace(mapRE1.cap(0), QString::fromLatin1("map<%1, %2>").arg(key, value)); + } else { + QRegExp mapRE2(QString::fromLatin1("map, ?%4\\s*>") + .arg(keyEsc, valueEsc, keyEsc, allocEsc)); + mapRE2.setMinimal(true); + if (mapRE2.indexIn(type) != -1) + type.replace(mapRE2.cap(0), QString::fromLatin1("map").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', gcc: 'pair' + 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(">")); + return type; +} } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/debuggerprotocol.h b/src/plugins/debugger/debuggerprotocol.h index ed46dc1948b..74dc21de286 100644 --- a/src/plugins/debugger/debuggerprotocol.h +++ b/src/plugins/debugger/debuggerprotocol.h @@ -221,6 +221,11 @@ enum DebuggerDisplay { // Decode string data as returned by the dumper helpers. QString decodeData(const QByteArray &baIn, int encoding); +// Simplify complicated STL template types, such as +// 'std::basic_string,std::allocator > '-> +// 'std::string'. +QString simplifySTLType(const QString &typeIn); + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 677dd1669aa..989bb39fc08 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -42,9 +42,8 @@ #include #include -#include - #include +#include #include #include #include @@ -478,7 +477,7 @@ static QString niceTypeHelper(const QByteArray &typeIn) const Cache::const_iterator it = cache.constFind(typeIn); if (it != cache.constEnd()) return it.value(); - const QString simplified = CPlusPlus::simplifySTLType(QLatin1String(typeIn)); + const QString simplified = simplifySTLType(QLatin1String(typeIn)); cache.insert(typeIn, simplified); // For simplicity, also cache unmodified types return simplified; } diff --git a/tests/auto/cplusplus/cplusplus.pro b/tests/auto/cplusplus/cplusplus.pro index c8258f90959..2a783402a0d 100644 --- a/tests/auto/cplusplus/cplusplus.pro +++ b/tests/auto/cplusplus/cplusplus.pro @@ -9,7 +9,6 @@ SUBDIRS = \ preprocessor \ semantic \ typeprettyprinter \ - simplifytypes \ misc \ cxx11 \ checksymbols \ diff --git a/tests/auto/cplusplus/cplusplus.qbs b/tests/auto/cplusplus/cplusplus.qbs index 0c64daffb2f..c5ec28e1c6a 100644 --- a/tests/auto/cplusplus/cplusplus.qbs +++ b/tests/auto/cplusplus/cplusplus.qbs @@ -13,7 +13,6 @@ Project { "misc/misc.qbs", "preprocessor/preprocessor.qbs", "semantic/semantic.qbs", - "simplifytypes/simplifytypes.qbs", "typeprettyprinter/typeprettyprinter.qbs" ] } diff --git a/tests/auto/cplusplus/simplifytypes/simplifytypes.pro b/tests/auto/cplusplus/simplifytypes/simplifytypes.pro deleted file mode 100644 index 7a952dbd25f..00000000000 --- a/tests/auto/cplusplus/simplifytypes/simplifytypes.pro +++ /dev/null @@ -1,2 +0,0 @@ -include(../shared/shared.pri) -SOURCES += tst_simplifytypestest.cpp diff --git a/tests/auto/cplusplus/simplifytypes/simplifytypes.qbs b/tests/auto/cplusplus/simplifytypes/simplifytypes.qbs deleted file mode 100644 index 877a79e7a86..00000000000 --- a/tests/auto/cplusplus/simplifytypes/simplifytypes.qbs +++ /dev/null @@ -1,7 +0,0 @@ -import qbs -import "../cplusplusautotest.qbs" as CPlusPlusAutotest - -CPlusPlusAutotest { - name: "CPlusPlus simplify types autotest" - files: "tst_simplifytypestest.cpp" -} diff --git a/tests/auto/debugger/debugger.pro b/tests/auto/debugger/debugger.pro index c3a4c6770b8..b280e393524 100644 --- a/tests/auto/debugger/debugger.pro +++ b/tests/auto/debugger/debugger.pro @@ -4,4 +4,5 @@ TEMPLATE = subdirs SUBDIRS += gdb.pro SUBDIRS += dumpers.pro SUBDIRS += namedemangler.pro +SUBDIRS += simplifytypes.pro diff --git a/tests/auto/debugger/debugger.qbs b/tests/auto/debugger/debugger.qbs index bd5b373e257..1139110f15d 100644 --- a/tests/auto/debugger/debugger.qbs +++ b/tests/auto/debugger/debugger.qbs @@ -7,5 +7,6 @@ Project { "dumpers.qbs", "gdb.qbs", "namedemangler.qbs" + "simplifytypes.qbs" ] } diff --git a/tests/auto/debugger/simplifytypes.pro b/tests/auto/debugger/simplifytypes.pro new file mode 100644 index 00000000000..04d995a3477 --- /dev/null +++ b/tests/auto/debugger/simplifytypes.pro @@ -0,0 +1,12 @@ +QTC_LIB_DEPENDS += utils +include(../qttest.pri) +QT += network +QT -= gui widgets + +DEBUGGERDIR = $$IDE_SOURCE_TREE/src/plugins/debugger + +INCLUDEPATH += $$DEBUGGERDIR + +SOURCES += \ + tst_simplifytypes.cpp \ + $$DEBUGGERDIR/debuggerprotocol.cpp \ diff --git a/tests/auto/debugger/simplifytypes.qbs b/tests/auto/debugger/simplifytypes.qbs new file mode 100644 index 00000000000..a32d8823976 --- /dev/null +++ b/tests/auto/debugger/simplifytypes.qbs @@ -0,0 +1,17 @@ +import qbs +import "../autotest.qbs" as Autotest + +Autotest { + name: "simplifytypes autotest" + Depends { name: "Qt.network" } // For QHostAddress + Group { + name: "Sources from Debugger plugin" + prefix: project.debuggerDir + files: "debuggerprotocol.cpp" + } + Group { + name: "Test sources" + files: "tst_simplifytypes.cpp" + } + cpp.includePaths: base.concat([project.debuggerDir]) +} diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index a499dd9014c..7c83376753a 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -318,7 +318,7 @@ struct Type } } QByteArray actualType = - CPlusPlus::simplifySTLType(QString::fromLatin1(actualType0)).toLatin1(); + simplifySTLType(QString::fromLatin1(actualType0)).toLatin1(); actualType.replace(' ', ""); actualType.replace("const", ""); QByteArray expectedType = type; diff --git a/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp b/tests/auto/debugger/tst_simplifytypes.cpp similarity index 97% rename from tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp rename to tests/auto/debugger/tst_simplifytypes.cpp index 0cbbe312fb4..056be1ee07a 100644 --- a/tests/auto/cplusplus/simplifytypes/tst_simplifytypestest.cpp +++ b/tests/auto/debugger/tst_simplifytypes.cpp @@ -27,11 +27,14 @@ ** ****************************************************************************/ -#include +#include "debuggerprotocol.h" #include #include +using namespace Debugger; +using namespace Internal; + const char *description[] = { "g++_stdstring", @@ -129,7 +132,7 @@ void SimplifyTypesTest::testCase1() { QFETCH(QString, input); QFETCH(QString, expected); - const QString output = CPlusPlus::simplifySTLType(input); + const QString output = simplifySTLType(input); QCOMPARE(output, expected); } @@ -145,4 +148,4 @@ void SimplifyTypesTest::testCase1_data() QTEST_APPLESS_MAIN(SimplifyTypesTest); -#include "tst_simplifytypestest.moc" +#include "tst_simplifytypes.moc"