Skip to content

Commit d795fb8

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Fix ordering of const and mutable keywords (facebook#56027)
Summary: Changelog: [Internal] The current implementation swaps the ordering of `const` and `mutable` keywords. This diff fixes it. Differential Revision: D95912404
1 parent 2be2770 commit d795fb8

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

scripts/cxx-api/parser/member.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ def to_string(
171171
if self.is_constexpr:
172172
result += "constexpr "
173173

174-
if self.is_const and not self.is_constexpr:
175-
result += "const "
176-
177174
if self.is_mutable:
178175
result += "mutable "
179176

177+
if self.is_const and not self.is_constexpr:
178+
result += "const "
179+
180180
if self._is_function_pointer():
181181
formatted_args = format_arguments(self._fp_arguments)
182182
qualified_type = format_parsed_type(self._parsed_type)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class test::Cache {
2+
public const int* constPtr;
3+
public mutable const int* mutableConstPtr;
4+
public mutable int* mutablePtr;
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 Cache {
13+
public:
14+
mutable int *mutablePtr;
15+
const int *constPtr;
16+
mutable const int *mutableConstPtr;
17+
};
18+
19+
} // namespace test

0 commit comments

Comments
 (0)