diff --git a/scripts/cxx-api/parser/member.py b/scripts/cxx-api/parser/member.py index 4f889afc1d4..7681b42dc1d 100644 --- a/scripts/cxx-api/parser/member.py +++ b/scripts/cxx-api/parser/member.py @@ -171,12 +171,12 @@ class VariableMember(Member): if self.is_constexpr: result += "constexpr " - if self.is_const and not self.is_constexpr: - result += "const " - if self.is_mutable: result += "mutable " + if self.is_const and not self.is_constexpr: + result += "const " + if self._is_function_pointer(): formatted_args = format_arguments(self._fp_arguments) qualified_type = format_parsed_type(self._parsed_type) diff --git a/scripts/cxx-api/tests/snapshots/should_handle_mutable_const_pointer_ordering/snapshot.api b/scripts/cxx-api/tests/snapshots/should_handle_mutable_const_pointer_ordering/snapshot.api new file mode 100644 index 00000000000..2066064f32f --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_handle_mutable_const_pointer_ordering/snapshot.api @@ -0,0 +1,5 @@ +class test::Cache { + public const int* constPtr; + public mutable const int* mutableConstPtr; + public mutable int* mutablePtr; +} diff --git a/scripts/cxx-api/tests/snapshots/should_handle_mutable_const_pointer_ordering/test.h b/scripts/cxx-api/tests/snapshots/should_handle_mutable_const_pointer_ordering/test.h new file mode 100644 index 00000000000..06b03e665c3 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_handle_mutable_const_pointer_ordering/test.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +namespace test { + +class Cache { + public: + mutable int *mutablePtr; + const int *constPtr; + mutable const int *mutableConstPtr; +}; + +} // namespace test