Skip to content

Commit 1fdddb0

Browse files
j-piaseckimeta-codesync[bot]
authored andcommitted
Fix double constexpr in constructors (#55846)
Summary: Pull Request resolved: #55846 Changelog: [Internal] When constructors are marked as "constexpr", doxygen will output them as a function of type "constexpr" with "is-constexpr=yes". This causes the script to duplicate the keyword. This diff fixes that by explicitly covering this edge case. Reviewed By: cipolleschi Differential Revision: D94901507 fbshipit-source-id: 384513381a86ba2efe07f14fd5976216ea5a8572
1 parent 44bb931 commit 1fdddb0

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

scripts/cxx-api/parser/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ def get_function_member(
324324
# Strip the trailing "=0" from the type string.
325325
function_type = re.sub(r"\s*=\s*0\s*$", "", function_type)
326326

327+
# For constexpr constructors, Doxygen outputs "constexpr" both as an
328+
# attribute (constexpr="yes") and as the return type (<type>constexpr</type>).
329+
# Remove the redundant type to avoid "constexpr constexpr" in output.
330+
if is_constexpr and function_type == "constexpr":
331+
function_type = ""
332+
327333
doxygen_params = get_doxygen_params(function_def)
328334

329335
function = FunctionMember(
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class test::Clss {
2+
public constexpr Clss() = default;
3+
public constexpr Clss(const test::Clss&) = default;
4+
public constexpr Clss(int value);
5+
public constexpr Clss(test::Clss&&) = default;
6+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
namespace test {
11+
12+
class Clss {
13+
public:
14+
constexpr Clss() = default;
15+
constexpr Clss(const Clss &) = default;
16+
constexpr Clss(Clss &&) = default;
17+
explicit constexpr Clss(int value);
18+
};
19+
20+
} // namespace test

0 commit comments

Comments
 (0)