Commit 1bc3a80
Normalize Objective-C nullability annotations (facebook#55898)
Summary:
Pull Request resolved: facebook#55898
Normalize Objective-C nullability annotations in the cxx-api parser to ensure consistent output in API snapshots.
Objective-C has three different forms of nullability annotations that are semantically equivalent:
- `nonnull`/`nullable` (context-sensitive keywords)
- `_Nonnull`/`_Nullable` (type qualifiers)
- `__nonnull`/`__nullable` (legacy Apple macros)
This diff normalizes all forms to `_Nonnull`/`_Nullable` for consistency.
**Examples:**
- `nonnull NSString*` → `_Nonnull NSString*`
- `NSString* __nonnull` → `NSString* _Nonnull`
- `nullable id` → `_Nullable id`
- `id __nullable` → `id _Nullable`
- `NSString* _Nonnull` → `NSString* _Nonnull` (unchanged)
Added a test case to verify the normalization works correctly.
Changelog:
[Internal]
Reviewed By: cortinico
Differential Revision: D95195669
fbshipit-source-id: ca2afd14b3c8bf7e62864daf9c3848f5d713898e1 parent 12da371 commit 1bc3a80
File tree
3 files changed
+58
-1
lines changed- scripts/cxx-api
- parser/utils
- tests/snapshots/should_normalize_nullability
3 files changed
+58
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
93 | 117 | | |
94 | 118 | | |
95 | 119 | | |
| |||
179 | 203 | | |
180 | 204 | | |
181 | 205 | | |
182 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
183 | 209 | | |
184 | 210 | | |
185 | 211 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments