(source: string)
| 1156 | 'g' |
| 1157 | ); |
| 1158 | export function blankCKernelAnnotations(source: string): string { |
| 1159 | if (source.indexOf('__') === -1) return source; |
| 1160 | C_KERNEL_ANNOTATION_RE.lastIndex = 0; |
| 1161 | if (!C_KERNEL_ANNOTATION_RE.test(source)) return source; |
| 1162 | let out = source.replace(C_KERNEL_ANNOTATION_RE, (m) => ' '.repeat(m.length)); |
| 1163 | // `container_of(ptr, struct T, member)` — the type-keyword argument is the |
| 1164 | // one call shape tree-sitter-c cannot read (a macro taking a TYPE), and it |
| 1165 | // is pervasive across the Linux tree. Blanking just the `struct`/`union` |
| 1166 | // keyword leaves `container_of(ptr, T, member)` — a plain |
| 1167 | // identifier argument the grammar parses natively. Keyed to the macro name |
| 1168 | // so no other `struct` keyword anywhere is ever touched. |
| 1169 | if (out.indexOf('container_of') !== -1) { |
| 1170 | out = out.replace( |
| 1171 | /(\bcontainer_of\s*\([^;()]*?,\s*)(struct|union)(\s+)/g, |
| 1172 | (_m, head: string, kw: string, ws: string) => head + ' '.repeat(kw.length) + ws |
| 1173 | ); |
| 1174 | } |
| 1175 | return out; |
| 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * Blank the PARAMETERIZED sparse/compiler annotations whole — name AND |
no outgoing calls
no test coverage detected