mirror of
				https://github.com/sphinx-doc/sphinx.git
				synced 2025-02-25 18:55:22 -06:00 
			
		
		
		
	C++, add proper template introduction mangling
This commit is contained in:
		| @@ -869,6 +869,14 @@ class ASTTemplateIntroductionParameter(ASTBase): | |||||||
|             else: |             else: | ||||||
|                 return '0'  # we need to put something |                 return '0'  # we need to put something | ||||||
|  |  | ||||||
|  |     def get_id_v2_as_arg(self): | ||||||
|  |         # used for the implicit requires clause | ||||||
|  |         res = self.identifier.get_id_v2() | ||||||
|  |         if self.parameterPack: | ||||||
|  |             return u'sp' + res | ||||||
|  |         else: | ||||||
|  |             return res | ||||||
|  |  | ||||||
|     def __unicode__(self): |     def __unicode__(self): | ||||||
|         res = [] |         res = [] | ||||||
|         if self.parameterPack: |         if self.parameterPack: | ||||||
| @@ -897,8 +905,14 @@ class ASTTemplateIntroduction(ASTBase): | |||||||
|         for param in self.params: |         for param in self.params: | ||||||
|             res.append(param.get_id_v2()) |             res.append(param.get_id_v2()) | ||||||
|         res.append("E") |         res.append("E") | ||||||
|         # TODO: add stuff for the implicit requires clause |         # let's use X expr E, which is otherwise for constant template args | ||||||
|         res.append("MissingRequiresMangling") |         res.append("X") | ||||||
|  |         res.append(self.concept.get_id_v2()) | ||||||
|  |         res.append("I") | ||||||
|  |         for param in self.params: | ||||||
|  |             res.append(param.get_id_v2_as_arg()) | ||||||
|  |         res.append("E") | ||||||
|  |         res.append("E") | ||||||
|         return ''.join(res) |         return ''.join(res) | ||||||
|  |  | ||||||
|     def __unicode__(self): |     def __unicode__(self): | ||||||
|   | |||||||
| @@ -422,31 +422,31 @@ def test_templates(): | |||||||
|     raises(DefinitionError, parse, 'enum', 'abc::ns::foo{id_0, id_1, id_2} A') |     raises(DefinitionError, parse, 'enum', 'abc::ns::foo{id_0, id_1, id_2} A') | ||||||
|     raises(DefinitionError, parse, 'enumerator', 'abc::ns::foo{id_0, id_1, id_2} A') |     raises(DefinitionError, parse, 'enumerator', 'abc::ns::foo{id_0, id_1, id_2} A') | ||||||
|     check('class', 'abc::ns::foo{id_0, id_1, id_2} xyz::bar', |     check('class', 'abc::ns::foo{id_0, id_1, id_2} xyz::bar', | ||||||
|           None, 'I000EMissingRequiresManglingN3xyz3barE') |           None, 'I000EXN3abc2ns3fooEI4id_04id_14id_2EEN3xyz3barE') | ||||||
|     check('class', 'abc::ns::foo{id_0, id_1, ...id_2} xyz::bar', |     check('class', 'abc::ns::foo{id_0, id_1, ...id_2} xyz::bar', | ||||||
|           None, 'I00DpEMissingRequiresManglingN3xyz3barE') |           None, 'I00DpEXN3abc2ns3fooEI4id_04id_1sp4id_2EEN3xyz3barE') | ||||||
|     check('class', 'abc::ns::foo{id_0, id_1, id_2} xyz::bar<id_0, id_1, id_2>', |     check('class', 'abc::ns::foo{id_0, id_1, id_2} xyz::bar<id_0, id_1, id_2>', | ||||||
|           None, 'I000EMissingRequiresManglingN3xyz3barI4id_04id_14id_2EE') |           None, 'I000EXN3abc2ns3fooEI4id_04id_14id_2EEN3xyz3barI4id_04id_14id_2EE') | ||||||
|     check('class', 'abc::ns::foo{id_0, id_1, ...id_2} xyz::bar<id_0, id_1, id_2...>', |     check('class', 'abc::ns::foo{id_0, id_1, ...id_2} xyz::bar<id_0, id_1, id_2...>', | ||||||
|           None, 'I00DpEMissingRequiresManglingN3xyz3barI4id_04id_1Dp4id_2EE') |           None, 'I00DpEXN3abc2ns3fooEI4id_04id_1sp4id_2EEN3xyz3barI4id_04id_1Dp4id_2EE') | ||||||
|  |  | ||||||
|     check('class', 'template<> Concept{U} A<int>::B', |     check('class', 'template<> Concept{U} A<int>::B', | ||||||
|           None, 'IEI0EMissingRequiresManglingN1AIiE1BE') |           None, 'IEI0EX7ConceptI1UEEN1AIiE1BE') | ||||||
|  |  | ||||||
|     check('type', 'abc::ns::foo{id_0, id_1, id_2} xyz::bar = ghi::qux', |     check('type', 'abc::ns::foo{id_0, id_1, id_2} xyz::bar = ghi::qux', | ||||||
|           None, 'I000EMissingRequiresManglingN3xyz3barE') |           None, 'I000EXN3abc2ns3fooEI4id_04id_14id_2EEN3xyz3barE') | ||||||
|     check('type', 'abc::ns::foo{id_0, id_1, ...id_2} xyz::bar = ghi::qux', |     check('type', 'abc::ns::foo{id_0, id_1, ...id_2} xyz::bar = ghi::qux', | ||||||
|           None, 'I00DpEMissingRequiresManglingN3xyz3barE') |           None, 'I00DpEXN3abc2ns3fooEI4id_04id_1sp4id_2EEN3xyz3barE') | ||||||
|     check('function', 'abc::ns::foo{id_0, id_1, id_2} void xyz::bar()', |     check('function', 'abc::ns::foo{id_0, id_1, id_2} void xyz::bar()', | ||||||
|           None, 'I000EMissingRequiresManglingN3xyz3barEv') |           None, 'I000EXN3abc2ns3fooEI4id_04id_14id_2EEN3xyz3barEv') | ||||||
|     check('function', 'abc::ns::foo{id_0, id_1, ...id_2} void xyz::bar()', |     check('function', 'abc::ns::foo{id_0, id_1, ...id_2} void xyz::bar()', | ||||||
|           None, 'I00DpEMissingRequiresManglingN3xyz3barEv') |           None, 'I00DpEXN3abc2ns3fooEI4id_04id_1sp4id_2EEN3xyz3barEv') | ||||||
|     check('member', 'abc::ns::foo{id_0, id_1, id_2} ghi::qux xyz::bar', |     check('member', 'abc::ns::foo{id_0, id_1, id_2} ghi::qux xyz::bar', | ||||||
|           None, 'I000EMissingRequiresManglingN3xyz3barE') |           None, 'I000EXN3abc2ns3fooEI4id_04id_14id_2EEN3xyz3barE') | ||||||
|     check('member', 'abc::ns::foo{id_0, id_1, ...id_2} ghi::qux xyz::bar', |     check('member', 'abc::ns::foo{id_0, id_1, ...id_2} ghi::qux xyz::bar', | ||||||
|           None, 'I00DpEMissingRequiresManglingN3xyz3barE') |           None, 'I00DpEXN3abc2ns3fooEI4id_04id_1sp4id_2EEN3xyz3barE') | ||||||
|     check('concept', 'Iterator{T, U} Another', |     check('concept', 'Iterator{T, U} Another', | ||||||
|           None, 'I00EMissingRequiresMangling7Another') |           None, 'I00EX8IteratorI1T1UEE7Another') | ||||||
|     check('concept', 'template<typename ...Pack> Numerics = (... && Numeric<Pack>)', |     check('concept', 'template<typename ...Pack> Numerics = (... && Numeric<Pack>)', | ||||||
|           None, 'IDpE8Numerics') |           None, 'IDpE8Numerics') | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user