(source: string)
| 2362 | 'g' |
| 2363 | ); |
| 2364 | export function blankCKernelAnnotations(source: string): string { |
| 2365 | if (source.indexOf('__') === -1) return source; |
| 2366 | C_KERNEL_ANNOTATION_RE.lastIndex = 0; |
| 2367 | if (!C_KERNEL_ANNOTATION_RE.test(source)) return source; |
| 2368 | let out = source.replace(C_KERNEL_ANNOTATION_RE, (m) => ' '.repeat(m.length)); |
| 2369 | // `container_of(ptr, struct T, member)` — the type-keyword argument is the |
| 2370 | // one call shape tree-sitter-c cannot read (a macro taking a TYPE), and it |
| 2371 | // is pervasive across the Linux tree. Blanking just the `struct`/`union` |
| 2372 | // keyword leaves `container_of(ptr, T, member)` — a plain |
| 2373 | // identifier argument the grammar parses natively. Keyed to the macro name |
| 2374 | // so no other `struct` keyword anywhere is ever touched. |
| 2375 | if (out.indexOf('container_of') !== -1) { |
| 2376 | out = out.replace( |
| 2377 | /(\bcontainer_of\s*\([^;()]*?,\s*)(struct|union)(\s+)/g, |
| 2378 | (_m, head: string, kw: string, ws: string) => head + ' '.repeat(kw.length) + ws |
| 2379 | ); |
| 2380 | } |
| 2381 | return out; |
| 2382 | } |
| 2383 | |
| 2384 | /** |
| 2385 | * Blank the PARAMETERIZED sparse/compiler annotations whole — name AND |
no outgoing calls
no test coverage detected