Repository navigation
Commit d7f4f75
authored
Suppress Clang unsafe-buffer warnings in generated C++ TurboModule headers
## Summary:
Fixes #60092.
The generated C++ TurboModule invoker indexes the raw argument pointer, which Clang rejects under -Wunsafe-buffer-usage. Suppress -Wunsafe-buffer-usage around the generated header body and restore it at the end of the file. The generated invokers keep their existing JSI pointer, count and argument checks.
Thanks to @YevheniiKotyrlo for the compiler reproduction. Codex helped implement and verify this fix.
## Changelog:
[GENERAL] [FIXED] - Suppress -Wunsafe-buffer-usage in generated C++ TurboModule headers.
## Test Plan:
- Generated SampleJSI.h with the repository's Codegen CLI and compiled a concrete TurboModule with Clang 19.1.7 using -std=c++20 -fsyntax-only -Werror -Wunsafe-buffer-usage. The original header failed on args[1]. The patched header compiled with Clang 19.1.7 and GCC 12.2 for required, optional, nullable and zero-argument methods. Clang still flags raw pointer indexing in a source file after it includes the generated header.
- yarn test --runInBand packages/react-native-codegen passed all 3,150 tests and 1,279 snapshots.
- ESLint and Prettier passed for GenerateModuleH.js. Full Android and iOS app builds were outside this compile regression.
Differential Revision: D132939887
Pull Request resolved: #601051 parent 845f593 commit d7f4f75
3 files changed
Lines changed: 224 additions & 0 deletions
File tree
- packages/react-native-codegen
- e2e/deep_imports/__tests__/modules/__snapshots__
- src/generators/modules
- __tests__/__snapshots__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
| |||
1594 | 1602 | | |
1595 | 1603 | | |
1596 | 1604 | | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
1597 | 1611 | | |
1598 | 1612 | | |
1599 | 1613 | | |
| |||
1612 | 1626 | | |
1613 | 1627 | | |
1614 | 1628 | | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
1615 | 1637 | | |
1616 | 1638 | | |
1617 | 1639 | | |
| |||
3191 | 3213 | | |
3192 | 3214 | | |
3193 | 3215 | | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
3194 | 3222 | | |
3195 | 3223 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 | | |
219 | 227 | | |
220 | 228 | | |
221 | 229 | | |
222 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
223 | 237 | | |
224 | 238 | | |
225 | 239 | | |
| |||
0 commit comments