From 0de923f5519f38db1b35453d2330b5705824c38a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Dec 2010 08:40:44 +0100 Subject: [PATCH] Debugger[New CDB]: Simplify MSVC version detection for std::map. --- src/libs/qtcreatorcdbext/containers.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/libs/qtcreatorcdbext/containers.cpp b/src/libs/qtcreatorcdbext/containers.cpp index 1a1ba1e456..51fc5103f8 100644 --- a/src/libs/qtcreatorcdbext/containers.cpp +++ b/src/libs/qtcreatorcdbext/containers.cpp @@ -543,8 +543,19 @@ void StdMapNode::debug(std::ostream &os, unsigned depth) const // Helper for std::map<>,std::set<> based on std::__Tree: // Return the list of children (pair for maps, direct children for set) static inline SymbolGroupValueVector - stdTreeNodChildList(const SymbolGroupValue &treeNode, int count) + stdTreeChildList(const SymbolGroupValue &tree, int count, bool *isMSVC2010In = 0) { + if (!count) + return SymbolGroupValueVector(); + // MSVC2010: "class _Tree : public _Tree_val: public _Tree_nod". + // MSVC2008: Direct class + const bool isMSVC2010 = tree[unsigned(0)][unsigned(0)]["_Mysize"].intValue() == count; + if (isMSVC2010In) + *isMSVC2010In = isMSVC2010; + const SymbolGroupValue treeNode = isMSVC2010 ? tree[unsigned(0)][unsigned(0)] : tree; + if (!treeNode) + return SymbolGroupValueVector(); + // Build the tree and iterate it. const StdMapNode *nodeTree = StdMapNode::buildMap(treeNode); if (!nodeTree) return SymbolGroupValueVector(); @@ -559,21 +570,6 @@ static inline SymbolGroupValueVector return rc; } -// Helper for std::map<>,std::set<> based on std::__Tree: -// Wrapper to distinguish MSVC2008/MSVC2010 -static inline SymbolGroupValueVector stdTreeChildList(const SymbolGroupValue &tree, int count, - bool *isMSVC2010 = 0) -{ - if (!count) - return SymbolGroupValueVector(); - // MSVC2010: "class _Tree : public _Tree_val: public _Tree_nod". - // MSVC2008: No base classes. - const SymbolGroupValueVector msvc2010Children = stdTreeNodChildList(tree[unsigned(0)][unsigned(0)], count); - if (isMSVC2010) - *isMSVC2010 = !msvc2010Children.empty(); - return msvc2010Children.empty() ? stdTreeNodChildList(tree, count) : msvc2010Children; -} - // std::set<>: Children directly contained in list static inline AbstractSymbolGroupNodePtrVector stdSetChildList(const SymbolGroupValue &set, int count) -- 2.11.0