Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default ctor for node types #2782

Merged
merged 8 commits into from
Jun 25, 2022
Merged

Conversation

fsb4000
Copy link
Contributor

@fsb4000 fsb4000 commented Jun 11, 2022

Fixes #2749

I used the test (clang-cl + C++20):

#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <hash_set>
#include <hash_map>
using namespace std;
int main() {
	list<int> l = { 1,2,3 };
	forward_list<int> f = { 1,2,3 };
	set<int> s = { 1,2,3 };
	multiset<int> ms = { 1,1,2,3 };
	map<int, char> m = { {1, 'a'}, {2,'b'} };
	multimap<int, char> mm = { {1, 'a'}, {1, 'c'}, {2,'b'} };
	unordered_set<int> us = { 1,2,3 };
	unordered_multiset<int> ums = { 1,1,2,3 };
	unordered_map<int, char> um = { {1, 'a'}, {2,'b'} };
	unordered_multimap<int, char> umm = { {1, 'a'}, {1, 'c'}, {2,'b'} };
/* Natvis errors
	stdext::hash_set<int> hs = { 1,2,3 };
	stdext::hash_multiset<int> hms = { 1,1,2,3 };
	stdext::hash_map<int, char> hm = { {1, 'a'}, {2,'b'} };
	stdext::hash_multimap<int , char> hmm = { {1, 'a'}, {1, 'c'}, {2,'b'} };
*/
}

Natvis log:

Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1234,8): Successfully parsed expression '_Mypair._Myval2._Myhead == 0' in type context 'std::forward_list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1235,8): Successfully parsed expression '_Mypair._Myval2._Myhead != 0' in type context 'std::forward_list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1237,57): Successfully parsed expression '_Mypair' in type context 'std::forward_list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1239,28): Successfully parsed expression '_Mypair._Myval2._Myhead' in type context 'std::forward_list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1240,28): Successfully parsed expression '_Next' in type context 'std::_Flist_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1241,26): Successfully parsed expression '_Myval' in type context 'std::_Flist_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1269,31): Successfully parsed expression '_Mypair._Myval2._Mysize' in type context 'std::list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1271,57): Successfully parsed expression '_Mypair' in type context 'std::list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1273,21): Successfully parsed expression '_Mypair._Myval2._Mysize' in type context 'std::list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1274,28): Successfully parsed expression '_Mypair._Myval2._Myhead->_Next' in type context 'std::list<int,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1275,28): Successfully parsed expression '_Next' in type context 'std::_List_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1276,26): Successfully parsed expression '_Myval' in type context 'std::_List_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1402,29): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::map<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1404,54): Successfully parsed expression '_Mypair' in type context 'std::map<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1405,53): Successfully parsed expression '_Mypair._Myval2' in type context 'std::map<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1407,15): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::map<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1408,22): Successfully parsed expression '_Mypair._Myval2._Myval2._Myhead->_Parent' in type context 'std::map<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1409,22): Successfully parsed expression '_Left' in type context 'std::_Tree_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1410,23): Successfully parsed expression '_Right' in type context 'std::_Tree_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1411,10): Successfully parsed expression '_Isnil == 0' in type context 'std::_Tree_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1411,68): Successfully parsed expression '_Myval,view(MapHelper)' in type context 'std::_Tree_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1411,12): Successfully parsed expression '_Myval.first' in type context 'std::_Tree_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1402,29): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::multimap<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1404,54): Successfully parsed expression '_Mypair' in type context 'std::multimap<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1405,53): Successfully parsed expression '_Mypair._Myval2' in type context 'std::multimap<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1407,15): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::multimap<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1408,22): Successfully parsed expression '_Mypair._Myval2._Myval2._Myhead->_Parent' in type context 'std::multimap<int,char,std::less<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1383,29): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::multiset<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1385,54): Successfully parsed expression '_Mypair' in type context 'std::multiset<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1386,53): Successfully parsed expression '_Mypair._Myval2' in type context 'std::multiset<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1388,15): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::multiset<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1389,22): Successfully parsed expression '_Mypair._Myval2._Myval2._Myhead->_Parent' in type context 'std::multiset<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1390,22): Successfully parsed expression '_Left' in type context 'std::_Tree_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1391,23): Successfully parsed expression '_Right' in type context 'std::_Tree_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1392,10): Successfully parsed expression '_Isnil == 0' in type context 'std::_Tree_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1392,44): Successfully parsed expression '_Myval' in type context 'std::_Tree_node<int,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1383,29): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::set<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1385,54): Successfully parsed expression '_Mypair' in type context 'std::set<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1386,53): Successfully parsed expression '_Mypair._Myval2' in type context 'std::set<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1388,15): Successfully parsed expression '_Mypair._Myval2._Myval2._Mysize' in type context 'std::set<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1389,22): Successfully parsed expression '_Mypair._Myval2._Myval2._Myhead->_Parent' in type context 'std::set<int,std::less<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1469,21): Successfully parsed expression '_List' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1471,58): Successfully parsed expression '_Maxidx' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1472,57): Successfully parsed expression '((float)_List._Mypair._Myval2._Mysize) / ((float)_Maxidx)' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1473,61): Successfully parsed expression '_Traitsobj._Mypair._Myval2._Myval2' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1474,57): Successfully parsed expression '_Traitsobj._Mypair' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1475,50): Successfully parsed expression '_Traitsobj._Mypair._Myval2' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1476,53): Successfully parsed expression '_List._Mypair' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1477,21): Successfully parsed expression '_List,view(MapHelper)' in type context 'std::unordered_map<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1269,31): Successfully parsed expression '_Mypair._Myval2._Mysize' in type context 'std::list<std::pair<const int,char>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1271,57): Successfully parsed expression '_Mypair' in type context 'std::list<std::pair<const int,char>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1273,21): Successfully parsed expression '_Mypair._Myval2._Mysize' in type context 'std::list<std::pair<const int,char>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1274,28): Successfully parsed expression '_Mypair._Myval2._Myhead->_Next' in type context 'std::list<std::pair<const int,char>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1275,28): Successfully parsed expression '_Next' in type context 'std::_List_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1276,26): Successfully parsed expression '_Myval' in type context 'std::_List_node<std::pair<const int,char>,void *>'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1469,21): Successfully parsed expression '_List' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1471,58): Successfully parsed expression '_Maxidx' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1472,57): Successfully parsed expression '((float)_List._Mypair._Myval2._Mysize) / ((float)_Maxidx)' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1473,61): Successfully parsed expression '_Traitsobj._Mypair._Myval2._Myval2' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1474,57): Successfully parsed expression '_Traitsobj._Mypair' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1475,50): Successfully parsed expression '_Traitsobj._Mypair._Myval2' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1476,53): Successfully parsed expression '_List._Mypair' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1477,21): Successfully parsed expression '_List,view(MapHelper)' in type context 'std::unordered_multimap<int,char,std::hash<int>,std::equal_to<int>,std::allocator<std::pair<const int,char> > >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1455,23): Successfully parsed expression '_List' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1457,62): Successfully parsed expression '_Maxidx' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1458,61): Successfully parsed expression '((float)_List._Mypair._Myval2._Mysize) / ((float)_Maxidx)' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1459,65): Successfully parsed expression '_Traitsobj._Mypair._Myval2._Myval2' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1460,61): Successfully parsed expression '_Traitsobj._Mypair' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1461,54): Successfully parsed expression '_Traitsobj._Mypair._Myval2' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1462,57): Successfully parsed expression '_List._Mypair' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1463,25): Successfully parsed expression '_List,view(simple)' in type context 'std::unordered_multiset<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1455,23): Successfully parsed expression '_List' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1457,62): Successfully parsed expression '_Maxidx' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1458,61): Successfully parsed expression '((float)_List._Mypair._Myval2._Mysize) / ((float)_Maxidx)' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1459,65): Successfully parsed expression '_Traitsobj._Mypair._Myval2._Myval2' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1460,61): Successfully parsed expression '_Traitsobj._Mypair' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1461,54): Successfully parsed expression '_Traitsobj._Mypair._Myval2' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1462,57): Successfully parsed expression '_List._Mypair' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.
Natvis: C:\Dev\STL\stl\debugger\STL.natvis(1463,25): Successfully parsed expression '_List,view(simple)' in type context 'std::unordered_set<int,std::hash<int>,std::equal_to<int>,std::allocator<int> >'.

изображение
I will create an issue about visualizer hash_set and hash_map, it doesn't work with Visual C++ either.

…cted and this fixing clang-cl debugger visualizer
@fsb4000 fsb4000 requested a review from a team as a code owner June 11, 2022 23:13
@fsb4000
Copy link
Contributor Author

fsb4000 commented Jun 11, 2022

@frederick-vs-ja, could you give an example when default ctors didn't work for you?

@frederick-vs-ja
Copy link
Contributor

I find that this is still insufficient for non-default-constructible element types...

For example, it seems that this example is not yet covered even after adding a (deleted) default ctor:

#include <list>

class NDCType {
private:
	int value_;
public:
	explicit constexpr NDCType(int x) noexcept : value_{x} {}
};

int main()
{
	std::list<NDCType> lsndc{NDCType{1}, NDCType{2}, NDCType{3}};
	return lsndc.size();
}

@fsb4000 fsb4000 marked this pull request as draft June 11, 2022 23:42
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Jun 12, 2022
@frederick-vs-ja
Copy link
Contributor

It seems that this workaround is possible

  • additionally giving _Myval a default member initializer = _Returns_exactly<_Value_type>().

Then the default constructor is always eligible (although calling it is ill-formed), and clang will not elide the debug info.

@fsb4000
Copy link
Contributor Author

fsb4000 commented Jun 22, 2022

Thank you @frederick-vs-ja !

test code:

#include <list>
#include <forward_list>
#include <set>

class NDCType {
private:
	int value_;
public:
	explicit constexpr NDCType(int x) noexcept : value_{ x } {}
	bool operator <(NDCType other) const {
		return value_ < other.value_;
	}
};

int main()
{
	std::list<NDCType> lsndc{ NDCType{1}, NDCType{2}, NDCType{3} };
	std::forward_list<NDCType> flsndc{ NDCType{1}, NDCType{2}, NDCType{3} };
	std::set<NDCType> sndc{ NDCType{1}, NDCType{2}, NDCType{3} };
	return 0;
}

изображение

@fsb4000 fsb4000 marked this pull request as ready for review June 22, 2022 15:56
stl/inc/forward_list Outdated Show resolved Hide resolved
stl/inc/forward_list Outdated Show resolved Hide resolved
stl/inc/forward_list Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej self-assigned this Jun 22, 2022
stl/inc/list Outdated Show resolved Hide resolved
stl/inc/xtree Show resolved Hide resolved
@StephanTLavavej StephanTLavavej removed their assignment Jun 23, 2022
@StephanTLavavej StephanTLavavej self-assigned this Jun 25, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 5c2d2ad into microsoft:main Jun 25, 2022
@StephanTLavavej
Copy link
Member

Thanks for investigating and fixing this surprising Clang/debugger interaction! 🔍 🛠️ 🎉

@fsb4000 fsb4000 deleted the fix2749 branch June 26, 2022 02:29
fsb4000 added a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Co-authored-by: A. Jiang <[email protected]>
Co-authored-by: Casey Carter <[email protected]>
Co-authored-by: Stephan T. Lavavej <[email protected]>
frederick-vs-ja referenced this pull request in CaseyCarter/STL Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

visual studio debugger doesn't show STL data when using clang against C++20
4 participants