summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Lykke Andersen <Jakob@caput.dk>2021-06-28 19:30:59 +0200
committerJakob Lykke Andersen <Jakob@caput.dk>2021-06-28 19:30:59 +0200
commit358efdd8f3bed92cac0177fb8f527a43e2e93fe1 (patch)
treea9ef9cb6f0bf586ef8fcd4293d230f1fdbb09843
parentc15c5cf3ee2157c5ae55a01ad4be147a780fe0e7 (diff)
downloadsphinx-git-358efdd8f3bed92cac0177fb8f527a43e2e93fe1.tar.gz
C++, fix name mangling of literals with digit seps
-rw-r--r--sphinx/domains/cpp.py2
-rw-r--r--tests/test_domain_cpp.py18
2 files changed, 10 insertions, 10 deletions
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index a3e0ae35c..09f938401 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -869,7 +869,7 @@ class ASTNumberLiteral(ASTLiteral):
def get_id(self, version: int) -> str:
# TODO: floats should be mangled by writing the hex of the binary representation
- return "L%sE" % self.data
+ return "L%sE" % self.data.replace("'", "")
def describe_signature(self, signode: TextElement, mode: str,
env: "BuildEnvironment", symbol: "Symbol") -> None:
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 1ad216e5a..e02cd8c1c 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -182,9 +182,9 @@ def test_domain_cpp_ast_expressions():
for u in unsignedSuffix:
for l in longSuffix:
expr = i + u + l
- exprCheck(expr, 'L' + expr + 'E')
+ exprCheck(expr, 'L' + expr.replace("'", "") + 'E')
expr = i + l + u
- exprCheck(expr, 'L' + expr + 'E')
+ exprCheck(expr, 'L' + expr.replace("'", "") + 'E')
decimalFloats = ['5e42', '5e+42', '5e-42',
'5.', '5.e42', '5.e+42', '5.e-42',
'.5', '.5e42', '.5e+42', '.5e-42',
@@ -200,10 +200,10 @@ def test_domain_cpp_ast_expressions():
for suffix in ['', 'f', 'F', 'l', 'L']:
for e in decimalFloats:
expr = e + suffix
- exprCheck(expr, 'L' + expr + 'E')
+ exprCheck(expr, 'L' + expr.replace("'", "") + 'E')
for e in hexFloats:
expr = "0x" + e + suffix
- exprCheck(expr, 'L' + expr + 'E')
+ exprCheck(expr, 'L' + expr.replace("'", "") + 'E')
exprCheck('"abc\\"cba"', 'LA8_KcE') # string
exprCheck('this', 'fpT')
# character literals
@@ -216,13 +216,13 @@ def test_domain_cpp_ast_expressions():
exprCheck("{}'{}'".format(p, c), t + val)
# user-defined literals
for i in ints:
- exprCheck(i + '_udl', 'clL_Zli4_udlEL' + i + 'EE')
- exprCheck(i + 'uludl', 'clL_Zli5uludlEL' + i + 'EE')
+ exprCheck(i + '_udl', 'clL_Zli4_udlEL' + i.replace("'", "") + 'EE')
+ exprCheck(i + 'uludl', 'clL_Zli5uludlEL' + i.replace("'", "") + 'EE')
for f in decimalFloats:
- exprCheck(f + '_udl', 'clL_Zli4_udlEL' + f + 'EE')
- exprCheck(f + 'fudl', 'clL_Zli4fudlEL' + f + 'EE')
+ exprCheck(f + '_udl', 'clL_Zli4_udlEL' + f.replace("'", "") + 'EE')
+ exprCheck(f + 'fudl', 'clL_Zli4fudlEL' + f.replace("'", "") + 'EE')
for f in hexFloats:
- exprCheck('0x' + f + '_udl', 'clL_Zli4_udlEL0x' + f + 'EE')
+ exprCheck('0x' + f + '_udl', 'clL_Zli4_udlEL0x' + f.replace("'", "") + 'EE')
for p, t in charPrefixAndIds:
for c, val in chars:
exprCheck("{}'{}'_udl".format(p, c), 'clL_Zli4_udlE' + t + val + 'E')