Skip to content

Commit 7f431bb

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Remove PROTOBUF_CONSTEXPR to unconditionally use constexpr
#test-continuous This was a legacy shim for C++11 and C++14 support, that's no longer needed. It also seems to be causing potential issues for unsupported compilers, when we disable it. PiperOrigin-RevId: 853822318
1 parent ce5ff11 commit 7f431bb

File tree

13 files changed

+101
-108
lines changed

13 files changed

+101
-108
lines changed

src/google/protobuf/compiler/cpp/file.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) {
589589
},
590590
R"cc(
591591
struct $type$ {
592-
PROTOBUF_CONSTEXPR $type$() : _instance{$default$} {}
592+
constexpr $type$() : _instance{$default$} {}
593593
union {
594594
$class$ _instance;
595595
};
@@ -639,7 +639,7 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) {
639639
},
640640
R"cc(
641641
struct $type$ {
642-
PROTOBUF_CONSTEXPR $type$() : _instance(::_pbi::ConstantInitialized{}) {}
642+
constexpr $type$() : _instance(::_pbi::ConstantInitialized{}) {}
643643
~$type$() {}
644644
//~ _instance must be the first member.
645645
union {
@@ -662,7 +662,7 @@ void FileGenerator::GenerateSourceDefaultInstance(int idx, io::Printer* p) {
662662
},
663663
R"cc(
664664
struct $type$ {
665-
PROTOBUF_CONSTEXPR $type$() : _instance(::_pbi::ConstantInitialized{}) {}
665+
constexpr $type$() : _instance(::_pbi::ConstantInitialized{}) {}
666666
~$type$() {}
667667
union {
668668
$class$ _instance;

src/google/protobuf/compiler/cpp/message.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) {
15551555
$pbi$::WireFormatLite::$val_wire_type$>;
15561556
$classname$();
15571557
template <typename = void>
1558-
explicit PROTOBUF_CONSTEXPR $classname$($pbi$::ConstantInitialized);
1558+
explicit constexpr $classname$($pbi$::ConstantInitialized);
15591559
explicit $classname$($pb$::Arena* $nullable$ arena);
15601560
static constexpr const void* $nonnull$ internal_default_instance() {
15611561
return &_$classname$_default_instance_;
@@ -2236,7 +2236,7 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* p) {
22362236
//~ Templatize constexpr constructor as a workaround for a bug in
22372237
//~ gcc 12 (warning in gcc 13).
22382238
template <typename = void>
2239-
explicit PROTOBUF_CONSTEXPR $classname$($pbi$::ConstantInitialized);
2239+
explicit constexpr $classname$($pbi$::ConstantInitialized);
22402240
22412241
inline $classname$(const $classname$& from) : $classname$(nullptr, from) {}
22422242
inline $classname$($classname$&& from) noexcept
@@ -3131,7 +3131,6 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
31313131

31323132
auto v = p->WithVars(ClassVars(descriptor_, options_));
31333133
auto t = p->WithVars(MakeTrackerCalls(descriptor_, options_));
3134-
auto c = p->WithVars({{"constexpr", "PROTOBUF_CONSTEXPR"}});
31353134
Formatter format(p);
31363135

31373136
if (IsMapEntryMessage(descriptor_) || !HasImplData(descriptor_, options_)) {
@@ -3147,7 +3146,7 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
31473146
//~ Templatize constexpr constructor as a workaround for a bug in
31483147
//~ gcc 12 (warning in gcc 13).
31493148
template <typename>
3150-
$constexpr$ $classname$::$classname$(::_pbi::ConstantInitialized)
3149+
constexpr $classname$::$classname$(::_pbi::ConstantInitialized)
31513150
#if defined(PROTOBUF_CUSTOM_VTABLE)
31523151
: $base$($classname$_class_data_.base()){}
31533152
#else // PROTOBUF_CUSTOM_VTABLE
@@ -3175,7 +3174,7 @@ void MessageGenerator::GenerateConstexprConstructor(io::Printer* p) {
31753174
p->Emit(
31763175
R"cc(
31773176
template <typename>
3178-
$constexpr$ $classname$::$classname$(::_pbi::ConstantInitialized)
3177+
constexpr $classname$::$classname$(::_pbi::ConstantInitialized)
31793178
#if defined(PROTOBUF_CUSTOM_VTABLE)
31803179
: $superclass$($classname$_class_data_.base()),
31813180
#else // PROTOBUF_CUSTOM_VTABLE

src/google/protobuf/compiler/java/java_features.pb.cc

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/compiler/java/java_features.pb.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/compiler/plugin.pb.cc

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/compiler/plugin.pb.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/cpp_features.pb.cc

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/cpp_features.pb.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)