Skip to content

Commit 0cb3e93

Browse files
committed
Detect constexpr functions
1 parent e97f7c9 commit 0cb3e93

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ class Resolver(object):
14681468
C_MODIFIERS = "* & const constexpr static mutable".split()
14691469
C_MODIFIERS = set(C_MODIFIERS)
14701470

1471-
C_KEYWORDS = "extern virtual static explicit inline friend".split()
1471+
C_KEYWORDS = "extern virtual static explicit inline friend constexpr".split()
14721472
C_KEYWORDS = set(C_KEYWORDS)
14731473

14741474
SubTypedefs = {} # TODO deprecate?

test/test_CppHeaderParser.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,21 @@ def test_fn(self):
29992999
self.assertEqual(p["defaultValue"], "0.02")
30003000

30013001

3002+
class ConstExprFn_TestCase(unittest.TestCase):
3003+
def setUp(self):
3004+
self.cppHeader = CppHeaderParser.CppHeader(
3005+
"""
3006+
constexpr int overloaded_constexpr(int a, int b, int c) { return a + b + c; }
3007+
""",
3008+
"string",
3009+
)
3010+
3011+
def test_fn(self):
3012+
m = self.cppHeader.functions[0]
3013+
self.assertEqual(m["constexpr"], True)
3014+
self.assertEqual(m["rtnType"], "int")
3015+
3016+
30023017
class DefaultEnum_TestCase(unittest.TestCase):
30033018
def setUp(self):
30043019
self.cppHeader = CppHeaderParser.CppHeader(

0 commit comments

Comments
 (0)