summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@digia.com>2014-10-13 08:36:58 +0200
committerDavid Schulz <david.schulz@digia.com>2014-10-15 09:53:00 +0200
commit4472437beb249faf59a51c96ee97890a015db4c7 (patch)
treefa6384b4242db7cef8f8e86a00b03527547008e4
parent5492dc4597b6d41f2dcdb1518a02ad40b2c3c3e9 (diff)
downloadqt-creator-4472437beb249faf59a51c96ee97890a015db4c7.tar.gz
CDB: Reverse the order of shadowed locals for newer cdbs.
The implementation have changed between the cdbs from Windows SDK 7 and 8. Fixed it to the behavior descriped in the comment above the change. Task-number: QTCREATORBUG-13132 Change-Id: I89aa2848b4f8f32c12daf305e7ed2ab2a7521ced Reviewed-by: Christian Stenger <christian.stenger@digia.com>
-rw-r--r--src/libs/qtcreatorcdbext/symbolgroupnode.cpp121
1 files changed, 71 insertions, 50 deletions
diff --git a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp
index f7d3e72901..083fe46150 100644
--- a/src/libs/qtcreatorcdbext/symbolgroupnode.cpp
+++ b/src/libs/qtcreatorcdbext/symbolgroupnode.cpp
@@ -693,40 +693,55 @@ bool SymbolGroupNode::notifyIndexesMoved(ULONG index, bool inserted, ULONG offse
return true;
}
-// Fix names: fix complicated template base names
-static inline void fixName(std::string *name)
-{
- // Long template base classes 'std::tree_base<Key....>' -> 'std::tree<>'
- // for nice display
- const std::string::size_type templatePos = name->find('<');
- if (templatePos != std::string::npos) {
- name->erase(templatePos + 1, name->size() - templatePos - 1);
- name->push_back('>');
+static inline void fixNameAndIname(unsigned &unnamedId, unsigned &templateId,
+ std::string &iname, std::string &name)
+{
+ if (name.empty() || name == "__formal") {
+ const std::string number = toString(unnamedId++);
+ name = "<unnamed " + number + '>';
+ iname = "unnamed#" + number;
+ } else {
+ // Fix names: fix complicated template base names
+ // Long template base classes 'std::tree_base<Key....>' -> 'std::tree<>'
+ // for nice display
+ std::string::size_type templatePos = name.find('<');
+ if (templatePos != std::string::npos) {
+ name.erase(templatePos + 1, name.size() - templatePos - 1);
+ name.push_back('>');
+ }
+
+ // Fix array iname "[0]" -> "0" for sorting to work correctly
+ if (!iname.empty() && iname.at(0) == '[') {
+ const std::string::size_type last = iname.size() - 1;
+ if (iname.at(last) == ']') {
+ iname.erase(last, 1);
+ iname.erase(0, 1);
+ return;
+ }
+ }
+ // Fix inames: arrays and long, complicated template base names
+ // Long template base classes 'std::tree_base<Key....' -> 'tree@t1',
+ // usable as identifier and command line parameter
+ templatePos = iname.find('<');
+ if (templatePos != std::string::npos) {
+ iname.erase(templatePos, iname.size() - templatePos);
+ if (iname.compare(0, 5, "std::") == 0)
+ iname.erase(0, 5);
+ iname.append("@t");
+ iname.append(toString(templateId++));
+ }
}
}
-// Fix inames: arrays and long, complicated template base names
-static inline void fixIname(unsigned &id, std::string *iname)
+static inline void addShadowCount(const StringVector::size_type count,
+ std::string &iname, std::string &name)
{
- // Fix array iname "[0]" -> "0" for sorting to work correctly
- if (!iname->empty() && iname->at(0) == '[') {
- const std::string::size_type last = iname->size() - 1;
- if (iname->at(last) == ']') {
- iname->erase(last, 1);
- iname->erase(0, 1);
- return;
- }
- }
- // Long template base classes 'std::tree_base<Key....' -> 'tree@t1',
- // usable as identifier and command line parameter
- const std::string::size_type templatePos = iname->find('<');
- if (templatePos != std::string::npos) {
- iname->erase(templatePos, iname->size() - templatePos);
- if (iname->compare(0, 5, "std::") == 0)
- iname->erase(0, 5);
- iname->append("@t");
- iname->append(toString(id++));
- }
+ const std::string number = toString(count);
+ name += " <shadowed ";
+ name += number;
+ name += '>';
+ iname += '#';
+ iname += number;
}
// Fix up names and inames
@@ -744,27 +759,33 @@ static inline void fixNames(bool isTopLevel, StringVector *names, StringVector *
if (true)
int x = 5; (2) // Occurrence (2), should be reported as name="x"/iname="x"
\endcode */
- StringVector::iterator nameIt = names->begin();
- const StringVector::iterator namesEnd = names->end();
- for (StringVector::iterator iNameIt = inames->begin(); nameIt != namesEnd ; ++nameIt, ++iNameIt) {
- std::string &name = *nameIt;
- std::string &iname = *iNameIt;
- if (name.empty() || name == "__formal") {
- const std::string number = toString(unnamedId++);
- name = "<unnamed " + number + '>';
- iname = "unnamed#" + number;
- } else {
- fixName(&name);
- fixIname(templateId, &iname);
+
+ const ExtensionContext::CdbVersion cdbVersion = ExtensionContext::instance().cdbVersion();
+ const bool reverseOrder = cdbVersion.major == 6 && cdbVersion.minor < 10;
+ if (reverseOrder) {
+ StringVector::reverse_iterator nameIt = names->rbegin();
+ const StringVector::reverse_iterator namesEnd = names->rend();
+ StringVector::reverse_iterator iNameIt = inames->rbegin();
+ for (; nameIt != namesEnd ; ++nameIt, ++iNameIt) {
+ std::string &name = *nameIt;
+ std::string &iname = *iNameIt;
+ fixNameAndIname(unnamedId, templateId, iname, name);
+ if (isTopLevel) {
+ if (const StringVector::size_type count = std::count(nameIt + 1, namesEnd, name))
+ addShadowCount(count, iname, name);
+ }
}
- if (isTopLevel) {
- if (const StringVector::size_type shadowCount = std::count(nameIt + 1, namesEnd, name)) {
- const std::string number = toString(shadowCount);
- name += " <shadowed ";
- name += number;
- name += '>';
- iname += '#';
- iname += number;
+ } else {
+ StringVector::iterator nameIt = names->begin();
+ const StringVector::iterator namesEnd = names->end();
+ StringVector::iterator iNameIt = inames->begin();
+ for (; nameIt != namesEnd ; ++nameIt, ++iNameIt) {
+ std::string &name = *nameIt;
+ std::string &iname = *iNameIt;
+ fixNameAndIname(unnamedId, templateId, iname, name);
+ if (isTopLevel) {
+ if (const StringVector::size_type count = std::count(nameIt + 1, namesEnd, name))
+ addShadowCount(count, iname, name);
}
}
}