Skip to content

Commit 44ce2a6

Browse files
committed
Fix build issue building component codegen using clang (microsoft#14393)
* Fix build issue building component codegen using clang * Change files
1 parent 53071e2 commit 44ce2a6

17 files changed

+107
-84
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix build issue building component codegen using clang",
4+
"packageName": "@react-native-windows/codegen",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix build issue building component codegen using clang",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/@react-native-windows/codegen/src/generators/GenerateComponentWindows.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ void Register::_COMPONENT_NAME_::NativeComponent(
188188
userData->UpdateEventEmitter(std::make_shared<::_COMPONENT_NAME_::EventEmitter>(eventEmitter));
189189
});
190190
191-
if constexpr (&TUserData::FinalizeUpdate != &Base::_COMPONENT_NAME_::<TUserData>::FinalizeUpdate) {
191+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &Base::_COMPONENT_NAME_::<TUserData>::FinalizeUpdate) {
192192
builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
193193
winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
194194
auto userData = view.UserData().as<TUserData>();
195195
userData->FinalizeUpdate(view, mask);
196196
});
197197
}
198198
199-
if constexpr (&TUserData::UpdateState != &Base::_COMPONENT_NAME_::<TUserData>::UpdateState) {
199+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &Base::_COMPONENT_NAME_::<TUserData>::UpdateState) {
200200
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
201201
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
202202
auto userData = view.UserData().as<TUserData>();
@@ -206,15 +206,15 @@ void Register::_COMPONENT_NAME_::NativeComponent(
206206
207207
::_REGISTER_CUSTOM_COMMAND_HANDLER_::
208208
209-
if constexpr (&TUserData::MountChildComponentView != &Base::_COMPONENT_NAME_::<TUserData>::MountChildComponentView) {
209+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &Base::_COMPONENT_NAME_::<TUserData>::MountChildComponentView) {
210210
builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
211211
const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
212212
auto userData = view.UserData().as<TUserData>();
213213
return userData->MountChildComponentView(view, args);
214214
});
215215
}
216216
217-
if constexpr (&TUserData::UnmountChildComponentView != &Base::_COMPONENT_NAME_::<TUserData>::UnmountChildComponentView) {
217+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &Base::_COMPONENT_NAME_::<TUserData>::UnmountChildComponentView) {
218218
builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
219219
const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
220220
auto userData = view.UserData().as<TUserData>();
@@ -224,13 +224,13 @@ void Register::_COMPONENT_NAME_::NativeComponent(
224224
225225
compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
226226
auto userData = winrt::make_self<TUserData>();
227-
if constexpr (&TUserData::Initialize != &Base::_COMPONENT_NAME_::<TUserData>::Initialize) {
227+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &Base::_COMPONENT_NAME_::<TUserData>::Initialize) {
228228
userData->Initialize(view);
229229
}
230230
view.UserData(*userData);
231231
});
232232
233-
if constexpr (&TUserData::CreateVisual != &Base::_COMPONENT_NAME_::<TUserData>::CreateVisual) {
233+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &Base::_COMPONENT_NAME_::<TUserData>::CreateVisual) {
234234
compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
235235
auto userData = view.UserData().as<TUserData>();
236236
return userData->CreateVisual(view);

vnext/Microsoft.ReactNative.Cxx/NativeModules.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,15 @@ inline ReactModuleProvider MakeTurboModuleProvider() noexcept {
14771477
return MakeModuleProvider<TModule>();
14781478
}
14791479

1480+
// Clang does not allow a virtual function address to be a constexpr statement
1481+
#if !defined(CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS)
1482+
#if defined(__clang__)
1483+
#define CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS
1484+
#else
1485+
#define CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS constexpr
1486+
#endif
1487+
#endif
1488+
14801489
} // namespace winrt::Microsoft::ReactNative
14811490

14821491
namespace React {

vnext/codegen/react/components/rnwcore/ActivityIndicatorView.g.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,31 +153,31 @@ void RegisterActivityIndicatorViewNativeComponent(
153153
userData->UpdateEventEmitter(std::make_shared<ActivityIndicatorViewEventEmitter>(eventEmitter));
154154
});
155155

156-
if constexpr (&TUserData::FinalizeUpdate != &BaseActivityIndicatorView<TUserData>::FinalizeUpdate) {
156+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseActivityIndicatorView<TUserData>::FinalizeUpdate) {
157157
builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
158158
winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
159159
auto userData = view.UserData().as<TUserData>();
160160
userData->FinalizeUpdate(view, mask);
161161
});
162162
}
163163

164-
if constexpr (&TUserData::UpdateState != &BaseActivityIndicatorView<TUserData>::UpdateState) {
164+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseActivityIndicatorView<TUserData>::UpdateState) {
165165
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
166166
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
167167
auto userData = view.UserData().as<TUserData>();
168168
userData->UpdateState(view, newState);
169169
});
170170
}
171171

172-
if constexpr (&TUserData::MountChildComponentView != &BaseActivityIndicatorView<TUserData>::MountChildComponentView) {
172+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseActivityIndicatorView<TUserData>::MountChildComponentView) {
173173
builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
174174
const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
175175
auto userData = view.UserData().as<TUserData>();
176176
return userData->MountChildComponentView(view, args);
177177
});
178178
}
179179

180-
if constexpr (&TUserData::UnmountChildComponentView != &BaseActivityIndicatorView<TUserData>::UnmountChildComponentView) {
180+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseActivityIndicatorView<TUserData>::UnmountChildComponentView) {
181181
builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
182182
const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
183183
auto userData = view.UserData().as<TUserData>();
@@ -187,13 +187,13 @@ void RegisterActivityIndicatorViewNativeComponent(
187187

188188
compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
189189
auto userData = winrt::make_self<TUserData>();
190-
if constexpr (&TUserData::Initialize != &BaseActivityIndicatorView<TUserData>::Initialize) {
190+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseActivityIndicatorView<TUserData>::Initialize) {
191191
userData->Initialize(view);
192192
}
193193
view.UserData(*userData);
194194
});
195195

196-
if constexpr (&TUserData::CreateVisual != &BaseActivityIndicatorView<TUserData>::CreateVisual) {
196+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseActivityIndicatorView<TUserData>::CreateVisual) {
197197
compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
198198
auto userData = view.UserData().as<TUserData>();
199199
return userData->CreateVisual(view);

vnext/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ void RegisterAndroidDrawerLayoutNativeComponent(
230230
userData->UpdateEventEmitter(std::make_shared<AndroidDrawerLayoutEventEmitter>(eventEmitter));
231231
});
232232

233-
if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidDrawerLayout<TUserData>::FinalizeUpdate) {
233+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseAndroidDrawerLayout<TUserData>::FinalizeUpdate) {
234234
builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
235235
winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
236236
auto userData = view.UserData().as<TUserData>();
237237
userData->FinalizeUpdate(view, mask);
238238
});
239239
}
240240

241-
if constexpr (&TUserData::UpdateState != &BaseAndroidDrawerLayout<TUserData>::UpdateState) {
241+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseAndroidDrawerLayout<TUserData>::UpdateState) {
242242
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
243243
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
244244
auto userData = view.UserData().as<TUserData>();
@@ -252,15 +252,15 @@ void RegisterAndroidDrawerLayoutNativeComponent(
252252
userData->HandleCommand(view, args);
253253
});
254254

255-
if constexpr (&TUserData::MountChildComponentView != &BaseAndroidDrawerLayout<TUserData>::MountChildComponentView) {
255+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseAndroidDrawerLayout<TUserData>::MountChildComponentView) {
256256
builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
257257
const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
258258
auto userData = view.UserData().as<TUserData>();
259259
return userData->MountChildComponentView(view, args);
260260
});
261261
}
262262

263-
if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidDrawerLayout<TUserData>::UnmountChildComponentView) {
263+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseAndroidDrawerLayout<TUserData>::UnmountChildComponentView) {
264264
builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
265265
const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
266266
auto userData = view.UserData().as<TUserData>();
@@ -270,13 +270,13 @@ void RegisterAndroidDrawerLayoutNativeComponent(
270270

271271
compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
272272
auto userData = winrt::make_self<TUserData>();
273-
if constexpr (&TUserData::Initialize != &BaseAndroidDrawerLayout<TUserData>::Initialize) {
273+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseAndroidDrawerLayout<TUserData>::Initialize) {
274274
userData->Initialize(view);
275275
}
276276
view.UserData(*userData);
277277
});
278278

279-
if constexpr (&TUserData::CreateVisual != &BaseAndroidDrawerLayout<TUserData>::CreateVisual) {
279+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseAndroidDrawerLayout<TUserData>::CreateVisual) {
280280
compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
281281
auto userData = view.UserData().as<TUserData>();
282282
return userData->CreateVisual(view);

vnext/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,31 @@ void RegisterAndroidHorizontalScrollContentViewNativeComponent(
141141
userData->UpdateEventEmitter(std::make_shared<AndroidHorizontalScrollContentViewEventEmitter>(eventEmitter));
142142
});
143143

144-
if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidHorizontalScrollContentView<TUserData>::FinalizeUpdate) {
144+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseAndroidHorizontalScrollContentView<TUserData>::FinalizeUpdate) {
145145
builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
146146
winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
147147
auto userData = view.UserData().as<TUserData>();
148148
userData->FinalizeUpdate(view, mask);
149149
});
150150
}
151151

152-
if constexpr (&TUserData::UpdateState != &BaseAndroidHorizontalScrollContentView<TUserData>::UpdateState) {
152+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseAndroidHorizontalScrollContentView<TUserData>::UpdateState) {
153153
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
154154
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
155155
auto userData = view.UserData().as<TUserData>();
156156
userData->UpdateState(view, newState);
157157
});
158158
}
159159

160-
if constexpr (&TUserData::MountChildComponentView != &BaseAndroidHorizontalScrollContentView<TUserData>::MountChildComponentView) {
160+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseAndroidHorizontalScrollContentView<TUserData>::MountChildComponentView) {
161161
builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
162162
const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
163163
auto userData = view.UserData().as<TUserData>();
164164
return userData->MountChildComponentView(view, args);
165165
});
166166
}
167167

168-
if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidHorizontalScrollContentView<TUserData>::UnmountChildComponentView) {
168+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseAndroidHorizontalScrollContentView<TUserData>::UnmountChildComponentView) {
169169
builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
170170
const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
171171
auto userData = view.UserData().as<TUserData>();
@@ -175,13 +175,13 @@ void RegisterAndroidHorizontalScrollContentViewNativeComponent(
175175

176176
compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
177177
auto userData = winrt::make_self<TUserData>();
178-
if constexpr (&TUserData::Initialize != &BaseAndroidHorizontalScrollContentView<TUserData>::Initialize) {
178+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseAndroidHorizontalScrollContentView<TUserData>::Initialize) {
179179
userData->Initialize(view);
180180
}
181181
view.UserData(*userData);
182182
});
183183

184-
if constexpr (&TUserData::CreateVisual != &BaseAndroidHorizontalScrollContentView<TUserData>::CreateVisual) {
184+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseAndroidHorizontalScrollContentView<TUserData>::CreateVisual) {
185185
compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
186186
auto userData = view.UserData().as<TUserData>();
187187
return userData->CreateVisual(view);

vnext/codegen/react/components/rnwcore/AndroidProgressBar.g.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,31 @@ void RegisterAndroidProgressBarNativeComponent(
165165
userData->UpdateEventEmitter(std::make_shared<AndroidProgressBarEventEmitter>(eventEmitter));
166166
});
167167

168-
if constexpr (&TUserData::FinalizeUpdate != &BaseAndroidProgressBar<TUserData>::FinalizeUpdate) {
168+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseAndroidProgressBar<TUserData>::FinalizeUpdate) {
169169
builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
170170
winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept {
171171
auto userData = view.UserData().as<TUserData>();
172172
userData->FinalizeUpdate(view, mask);
173173
});
174174
}
175175

176-
if constexpr (&TUserData::UpdateState != &BaseAndroidProgressBar<TUserData>::UpdateState) {
176+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseAndroidProgressBar<TUserData>::UpdateState) {
177177
builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
178178
const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept {
179179
auto userData = view.UserData().as<TUserData>();
180180
userData->UpdateState(view, newState);
181181
});
182182
}
183183

184-
if constexpr (&TUserData::MountChildComponentView != &BaseAndroidProgressBar<TUserData>::MountChildComponentView) {
184+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseAndroidProgressBar<TUserData>::MountChildComponentView) {
185185
builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
186186
const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept {
187187
auto userData = view.UserData().as<TUserData>();
188188
return userData->MountChildComponentView(view, args);
189189
});
190190
}
191191

192-
if constexpr (&TUserData::UnmountChildComponentView != &BaseAndroidProgressBar<TUserData>::UnmountChildComponentView) {
192+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseAndroidProgressBar<TUserData>::UnmountChildComponentView) {
193193
builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
194194
const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept {
195195
auto userData = view.UserData().as<TUserData>();
@@ -199,13 +199,13 @@ void RegisterAndroidProgressBarNativeComponent(
199199

200200
compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
201201
auto userData = winrt::make_self<TUserData>();
202-
if constexpr (&TUserData::Initialize != &BaseAndroidProgressBar<TUserData>::Initialize) {
202+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseAndroidProgressBar<TUserData>::Initialize) {
203203
userData->Initialize(view);
204204
}
205205
view.UserData(*userData);
206206
});
207207

208-
if constexpr (&TUserData::CreateVisual != &BaseAndroidProgressBar<TUserData>::CreateVisual) {
208+
if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseAndroidProgressBar<TUserData>::CreateVisual) {
209209
compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
210210
auto userData = view.UserData().as<TUserData>();
211211
return userData->CreateVisual(view);

0 commit comments

Comments
 (0)