aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2019-09-03 10:16:06 +0200
committerDavid Schulz <david.schulz@qt.io>2019-09-09 11:35:24 +0000
commitd72632acd646eb6dd4552a0a7ddd30ea3dacd46f (patch)
tree2d62e2b118f2c299ea329d2a7c0ab71976da245b
parentf1e3484cd7a86664ec2094230bab741f768f050c (diff)
Debugger: add dumper for std::initializer_list
Change-Id: I223182cecf1f04dbc9908dc993a8800c1633c48b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--share/qtcreator/debugger/stdtypes.py18
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp27
2 files changed, 45 insertions, 0 deletions
diff --git a/share/qtcreator/debugger/stdtypes.py b/share/qtcreator/debugger/stdtypes.py
index bdbaea14d5..2f51aa2ec1 100644
--- a/share/qtcreator/debugger/stdtypes.py
+++ b/share/qtcreator/debugger/stdtypes.py
@@ -1039,6 +1039,24 @@ def qdump__std____debug__vector(d, value):
qdump__std__vector(d, value)
+def qdump__std__initializer_list(d, value):
+ innerType = value.type[0]
+ if d.isMsvcTarget():
+ start = value["_First"].pointer()
+ end = value["_Last"].pointer()
+ size = int((end - start) / innerType.size())
+ else:
+ try:
+ start = value["_M_array"].pointer()
+ size = value["_M_len"].integer()
+ except:
+ start = value["__begin_"].pointer()
+ size = value["__size_"].integer()
+
+ d.putItemCount(size)
+ if d.isExpanded():
+ d.putPlotData(start, size, innerType)
+
def qedit__std__string(d, value, data):
d.call('void', value, 'assign', '"%s"' % data.replace('"', '\\"'))
diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp
index 026846e7db..5f8dc1e4f4 100644
--- a/tests/auto/debugger/tst_dumpers.cpp
+++ b/tests/auto/debugger/tst_dumpers.cpp
@@ -5148,6 +5148,33 @@ void tst_Dumpers::dumper_data()
+ Check("set2.0", "[0]", "42", "int")
+ Check("set2.1", "[1]", "42", "int");
+ QTest::newRow("StdInitializerList")
+ << Data("#include <initializer_list>\n",
+ "auto initb = {true, false, false, true};\n"
+ "auto initi = {1, 2, 3};\n"
+ "auto inits = {\"1\", \"2\", \"3\"};\n"
+ "std::initializer_list<int> empty;\n"
+ "unused(&initb, &initi, &inits, &empty);\n")
+
+ + Cxx11Profile()
+
+ + Check("initb", "<4 items>", "std::initializer_list<bool>")
+ + Check("initb.0", "[0]", "1", "bool") // 1 -> true is done on display
+ + Check("initb.1", "[1]", "0", "bool")
+ + Check("initb.2", "[2]", "0", "bool")
+ + Check("initb.3", "[3]", "1", "bool")
+
+ + Check("initi", "<3 items>", "std::initializer_list<int>")
+ + Check("initi.0", "[0]", "1", "int")
+ + Check("initi.1", "[1]", "2", "int")
+ + Check("initi.2", "[2]", "3", "int")
+
+ + Check("inits", "<3 items>", "std::initializer_list<const char *>")
+ + Check("inits.0", "[0]", "\"1\"", "char*")
+ + Check("inits.1", "[1]", "\"2\"", "char*")
+ + Check("inits.2", "[2]", "\"3\"", "char*")
+
+ + Check("empty", "<0 items>", "std::initializer_list<int>");
// class Goo
// {